I've been working on Mario for a week now. I have found a pattern to create the spaces (which I am replacing with underscores just to see how my code outputs) but they are not printing at all. I also cannot figure out how to print the hashes. I know it has to do with the line you're on vs. the number of lines total as we start out with 2, then 3, then 4 regardless of what the user input for height is. Here's my code:
#include <stdio.h>
#include <cs50.h>
int rows;
int main(void)
{
do
{
printf("Height: ");
rows = GetInt();
}
while (rows > 23 || rows < 1);
int x;
int spaces;
int hashes;
for (x = 0; x < rows; x++)
{
for (spaces = (rows - 1); spaces == 0; spaces--)
{
printf("_");
}
for (hashes = 0; hashes < 24; hashes++)
{
printf("#");
}
printf("\n");
}
}
My output is this:
Height: 3
# # #I drew out the pyramid a few times (like the computer would) trying to see a solution. It helped earlier but I am just stuck now. I feel like I am really close to the solution. A hint or a breadcrumb please!