0

The spec requires that there are two spaces between the left section of hashes and the right section of hashes. As you'll see below, when using two spaces, it fails, however when I use one, it passes. I've tried changing it to one space and adding another printf to print another space, but I get the same errors. I cant think of anything else it could be.

      for (int j = 0; j < 2 ; j++)
      {
          printf("  ");
      }

Here is the error:

~/workspace/pset1/ $ check50 2016.mario.more mario.c
:) mario.c exists
:) mario.c compiles
:) rejects a height of -1
:) handles a height of 0 correctly
:) handles a height of 1 correctly
:( handles a height of 2 correctly
   \ expected output, but not "  #  #\n##  ##\n"
:( handles a height of 23 correctly
   \ expected output, but not "                                       ..."
:) rejects a height of 24
:) rejects a non-numeric height of "foo"
:) rejects a non-numeric height of ""
https://sandbox.cs50.net/checks/a368e0da675b41db8d037a5361daf077
0

Take a look at the sandbox output (you posted the link above), especially for the height = 23 test. It's immediately obvious that the problem isn't the spacing between the two halves of the pyramid. The problem lies in the number of leading spaces on each line. Since it appears that you were looking in the wrong place, I'll give you a chance to find the underlying cause. ;-)

This is also a great demonstration of why it is occassionally good to change the output for testing. If this happened to me, I'd print a viewable character anywhere a space is required to be able to count them. ;-)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

0

The problem was that the for loop to add the spaces ran twice, therefore adding 4 spaces in total. It all works fine now.

You must log in to answer this question.

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