#include <stdio.h>
#include <cs50.h>
int main(void)
{
int block;
do
{
printf("Height: ");
block = get_int();
}
while (block < 0 || block > 23);
// printf("You have selected to create %i blocks\n", block);
for (int height = 0; height < block; height++)
{
for (int spaces = 0; spaces < block-height-1; spaces++)
{
printf(" ");
}
for (int hashes = 0; hashes < height +1; hashes ++)
{
printf("#");
}
printf(" ");
for (int hashes2 = 0; hashes2 < height +1; hashes2 ++)
{
printf("#");
}
printf("\n");
}
}
Hi everyone, this is my code and during the test it outputs what I believe is the same as what check50 is meant to be checking for.
The error I get is:
:( 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"
From the search I've done on stackexchange it seems that previous users with the same error either had a space on the right hand pyramid or there is a double space in between the two pyramids. I feel that my code does avoid both of the problems.
Can someone please explain to me what the error is trying to point out as it seems my code matches the check.
Thanks
Alex