// build pyramid and row by adding spaces and X
int row, space, X, n;
n = GetInt();
row = n; space = n;
X = 0;
do
{
do
{
printf(" ");
space--;
printf("x\n");
X++;
row--;
}
while (space > 0);
1 Answer
Your do while loop is causing part of the problem. You might want to get rid of int row because it may not have any use in mario.c. You might want to set up a for loop for spaces and a for loop for hashes/sharps/# all inside a do/while loop. Try that! You should be starting out like this:
int space, x, n; //x as hashes/sharps
n = GetInt(); //make sure to prompt user to type in a height
space = n-1; // number of spaces in first row
x = ???; //what would be the number of hashes in the 1st row every single time?
do
{
int y;
int z;
for(y=space; y > 0; y = y--)
{
printf(//space);
}
//then set a for loop for hashes/sharps
//after, print new line
n = n-1; //height is decreasing
space = ???; //how much is spaces decreasing?
x = ???; //how much is hashes/sharps increasing?
}
while (//height has to be greater than...)
X
is being used for - is this meant to be a pound / sharp / hash character#
?