1

I have sent my code for the pset of mario, he is working but i have only 55% and i dont know why ! I have search the soluce on the web to compare but didnt found !

Can someone look on my program to telling me what's wrong with it ?

best regards,

#include <cs50.h>
#include <stdio.h>
int main(void)
{
   int n;
    do{
       n = get_int("Height: ");

    }

while (n > 8 || n <1 );

    for (int i = 0; i < n; i++)
    {
                  int b;
    for (b = 0; b < n-i+1; b++)
    {
        printf(" ");
    }
        int c;
         for (c = 0; c < i+1; c++)
         {
                   printf("#");  
         }

                   printf("\n");
    }



}
1

EVERY line in the pyramid has leading spaces. The last line should not have any leading spaces and each line above the last should have one more space than the line below it.

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

5
  • it's just the text on the left who have more space between lines, but there is no leading space ( if you talk about the space between the lines ) :(
    – Lyphard
    Mar 8 '19 at 23:22
  • Change the space in the code to something printable and watch what happens. Also, make sure that you've recompiled and are using the code posted above.
    – Cliff B
    Mar 8 '19 at 23:29
  • i have tried before, but the space between the lines are too much large. In the code there are unusual things ? maybe all the variable must be on the top of the code ?
    – Lyphard
    Mar 8 '19 at 23:39
  • Forget about vertical spacing. It has no bearing on this assignment. Look at the spaces at the beginning of each line. Replace " " with "x" so that you can see what's actually being printed. When you get it fixed, put the space back.
    – Cliff B
    Mar 8 '19 at 23:48
  • Thank you, you are right, there where two space too much, i mustchange the n-i+1 by -1 ! i will send and see what happen!
    – Lyphard
    Mar 9 '19 at 0:32

You must log in to answer this question.

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