I've messed with this program for awhile, i can't figure out how to make any of the other triangular shapes beyond the first one i have. Also there's a diamond that i am supposed to make, and a triangle with spaces in the problem. Can anyone help me re-construct my for(int ------) statements in my code? thanks :)

#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main()
{
// make triangle 
// X
// XX
// XXX
// XXXX
// XXXXX
// XXXXXX
int rowSize;
cout << "Please enter the number of rows between 3 and 6 for a triangle: ";
cin >> rowSize;
for (int r=0;r<rowSize;r++)
{
	for(int c=0;c<r+1;c++)
	{
		cout << "*";
	}
	cout << endl;
}
{ 
	// Make triangle shaped different like so:
	// ******
	// *****
	// ****
	// ***
	// **
	// *
	int rowSize;
	cout << "Please enter another row size for a different triangular shape: ";
	cin  >> rowSize;
	for (int r=0;r<rowSize;r++)
	{
	for (int c=0;c<r-1;c++)
	{
		cout << "*";
	}
	cout << endl;
	}
}
{	
// Make triangle shaped like so(- stands for blank space)
	// ----*
	// ---**
	// --***
	// -****
	// *****
	int rowSize;
	cout << "Please enter another row size for a different triangular shape: ";
		cin >> rowSize;
		for (int r=0;r<rowSize;r++)
		{
			for (int c=0;c<r+1;c++)
			{ 
				cout << "*";
			}
			cout << endl;
		}
}
{
// Make a Diamond shape like so
//    *
//   ***
//  *****
// *******
//  *****
//   ***
//    *
	int rowSize;
	cout << "Please enter another row size for a diamond: ";
	cin >> rowSize;
	for (int r=0;r<rowSize;r++)
	{
		for (int c=0;c<r+1;c++)
		{
			cout << "*";
		}
		cout << endl;
	}
}


	
system("pause");
return 0;
}

I see that you pretty much nailed the first 1 :).
Now lets look at the next one.

Doesn't it seem to be the exact reverse of the first 1 ?
So if its the reverse, the starting values and the conditions in the loop also would be reversed right? ;)

Okay so i tried reversing a little, and it still doesn't seem to work. I'm sure it's because i'm probably thinking too hard about it, but this is what i changed it to, and it still is not working:

for (int c=0;c<rowSize;c++)
{
	for(int r=0;r<c+1;r++)

Think of it like this,
For the 1st row u need to print n '*'.
for the second u need (n-1)
for the 3rd u need (n-2).

So do you see the connection ?

hmmm still not quite sure how the format of it is supposed to be. Your hints are really helping me try a bunch of new things though! Could you show how it should look in the code? And do you have any suggestions on the other triangle shape after that? and the diamond?

Just go through the first code and try to anlayse..
How many '*' is it printing on the first line. and what was the value of the variables.

It wouldn't help if I provided u with the code. So I actually cant.

okay thanks for the help. Any idea on the diamond shape?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.