I am having trouble creating an inverted half-square out asterisks. The problem requires three nested for-loops, I believe, but am unsure as how to proceed. Here is the work I have so far, with the UN-inverted half-square code in italics. The inverted portion should be a simple manipulation of that code, I would think.
#include <iostream.h>
int main()
{
using namespace std;
int height, SIZE, runNum;
string figType;
// Allows all three figures to be created in one run, if so desired.
cout<< "How many times do you want to run this program?\t\t";
cin>> runNum;
for(int j=0; j<runNum; j++)
{
// Decides which figure will be created, a square (S),
// half-square (H), or rectangle (B)
cout<< "\n\n\nEnter figure type (S, H, B)\t\t\t\t";
cin>> figType;
// Creates the square figure out of asterisks (S)
if(figType == "S")
{
cout<< "Enter width of figure\t\t\t\t\t";
cin>> SIZE;
for(int cols = 1; cols <= SIZE; cols ++)
{
cout<< "*";
for(int rows = 1; rows <= (SIZE-1); rows ++)
{
cout<< "*";
}
cout<< "\n";
}
}
[I] // Creates the half-square figure (H)
if(figType == "H")
{
cout<< "Enter width of figure\t\t\t\t\t";
cin>> SIZE;
for(int cols = 1; cols <= SIZE; cols ++)
{
for(int rows = 1; rows <= cols; rows ++)
{
cout<< "*";
}
cout<< "\n";
}
}[/I]
// Creates the rectangle figure out of asterisks (B)
if(figType == "B")
{
cout<< "Enter width of figure\t\t\t\t\t";
cin>> SIZE;
cout<< "Enter height of figure\t\t\t\t\t";
cin>> height;
for(int cols = 1; cols <= height; cols ++)
{
cout<< "*";
// Determines width of rectangle
for(int rows = 1; rows <= (SIZE-1); rows ++)
{
cout<< "*";
}
cout<< "\n";
}
}
}
cout<< "\n\nCaleb Cordes\nHexadecimal\nAsterisks";
return 0;
}