0

So this is new code more comfortable Mario

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

int main(void)
{
    int height;
    int space;
    int hash;
    int i= 0;
    do
    {
        printf ("Height:");
        height = GetInt();
    }
    while (height < 0 || height > 23);
    //loop for the rows generation
    for (i = 0; i < height; i++)

    {  
        //loop for the spaces and Hashes printed per row
        for (space = (height - i) ; space > 0; space--)
        {
            printf(" ");
        }
        for (hash = 0; hash < (i + 1); hash++)
        {
            printf("#");
        }
         //lfor middle space
        {
            printf("  ");
        }
        //loop for right pyramid
         for (hash = 0; hash < (i + 1); hash++)
        {
            printf("#");
        }
       printf("\n");
    }  
    return 0;
}

it prints

    #  #
   ##  ##
  ###  ###
 ####  ####

But the errors are still there

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

edited question

From the spec:

Take care to left-align the bottom-left corner of the left-hand half-pyramid with the left-hand edge of your terminal window.

In other words, the last line must start in the first "column" of the screen.

(+1 for editing the code format :)


original question
Assuming "more comfortable" version and your sample is for height 4, your output does not look like the expected output from the spec. To wit:

Implement a program that prints out a double half-pyramid of a specified height, per the below.

   $ ./mario  
    Height: 4  
       #  #  
      ##  ##  
     ###  ###  
    ####  ####  

Hint for formatting code on Stack Exchange: after you paste the code click the {} icon in the formatting bar, and ta-da it's done.

1
  • Please take a look, I have edited the question. Jan 9 '17 at 19:42

You must log in to answer this question.

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