0

I was so happy that I finally finished the mario en greedy pset. It compiled and worked fine. But when I try to check the mario pset with cs50 check, it gives me these errors:

:) mario.c exists

:) mario.c compiles

:) rejects a height of -1

:) handles a height of 0 correctly

:( handles a height of 1 correctly \ expected output, but not "## \n"

:( handles a height of 2 correctly \ expected output, but not " ## \n### \n"

:( handles a height of 23 correctly \ expected output, but not " ## \n ..."

:( rejects a height of 24 \ expected output, but not " ## \n ..."

:) rejects a non-numeric height of "foo"

:) rejects a non-numeric height of ""

This is my code:

int main(void)
{
    //Prompts the users for a height value
    int height;

do
{
    printf("Height: ");
    height = GetInt();
}
while (height < 0 || height >= 24);

//Prints half-pyramid with chosen valuess
for (int row = 0; row < height; row++)
{     
    for (int spaces = height; spaces - 1 > row; spaces--)
    {
        printf(" ");
    }

    for (int column = 0; column < row + 2; column++)
    {
        printf("#");
    }

    printf(" \n");
}
}

Could someone else try to compile it and test it and give me some feedback? Thanks for the help!

0

Bram, I don't need to load and run your code, the error messages from check50 are giving you all the information you need. Remember, in this assignment the location of spaces and # is the key. Study this output

"## \n"

from check50 to find your mistake.

| improve this answer | |
0

It seems correct but not 'exactly' correct. Went through this myself last week.

| improve this answer | |
  • Yeah, I found the little bug. Luckily there was the cs50 check, because I'd have sent that... – Bram Vanbilsen Nov 1 '15 at 17:35

You must log in to answer this question.

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