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;
}