I just finished my mario pyramid, and tried myself, everything works. But in check50...
:) mario.c exists.
:) mario.c compiles.
:) rejects a height of -1
:) handles a height of 0 correctly
:( handles a height of 1 correctly
expected "# #\n", not "# #\n"
:( handles a height of 2 correctly
expected " # #\n## ##\n", not " # #\n## ##\n"
:( handles a height of 23 correctly
expected " ...", not " ..."
:( rejects a height of 24, and then accepts a height of 2
expected " # #\n## ##\n", not " # #\n## ##\n"
:) rejects a non-numeric height of "foo"
:) rejects a non-numeric height of ""
Which seems identical to what it expected...
Any idea if I missed anything?
Here is my code.
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int height = get_int("Height: ");
char brick = '#';
char space = ' ';
int initial = 0;
while (height < 0 || height > 23)
{
height = get_int("Height: ");
};
while (initial < height)
{
for (int i = initial; i < height - 1; i++)
{
printf("%c""%c %c", space, space);
};
for (int i = 0; i < initial + 1; i++)
{
printf("%c", brick);
if (i == initial)
{
printf("%c", space);
for (int j = 0; j < initial + 1; j++)
{
printf("%c", brick);
};
};
};
printf("\n");
initial++;
};
}