0

So i am failing these checks:

:( 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" 

Then under these checks there is expected output and my output, but they are the same :S

#include <cs50.h>
#include <stdio.h>

int main(void)
    {
    // H stands for height of the pyramid
    int H;

    // Check the input
    do
    {

        H = get_int("Height: ");

    }
    while (H < 0 || H > 23);

    // Start the for loop, for each row
    for (int row = 0; row < H; row++)
    {
        // First pyramid
        for (int space = 0; space < H - ( row + 1 ); space++)
        {
            printf(" ");
        }

        for (int hash = 0; hash < row + 1; hash++)
        {
            printf("#");
        }

        // Print the space between the pyramids
        printf(" ");

        // And the second one
        for (int hash2 = 0; hash2 < row + 1; hash2++)
        {
            printf("#");
        }

        printf("\n");
    } 
}

I don't know what is wrong with those checks.

0

In this case we can compare your output with the implementation of the staff, see which is the staff:

~/workspace/ $ ~cs50/hacker1/mario
Height: 2
 #  #
##  ##

and now observes what is your output:

Height: 2
 # #
## ##

as you see there is a problem with the space between hashtag, check50 expects an exact output to the staff

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .