I know this question has been asked several times but I haven't found an answer that worked for the issue I have. The output for my pset1 Mario more comfortable seems to be correct (including no extra spaces at the end of the second pyramid) yet I get this from check50 :
:) mario.c exists
:) mario.c compiles
:) rejects a height of -1
:) rejects a height of 0
:( handles a height of 1 correctly
expected ""# #"", not ""#""
:( handles a height of 2 correctly
expected "" # #"\n"## ...", not "" #"\n"##""
:( handles a height of 8 correctly
expected "" # #"\...", not "" #"\n" ..."
:( rejects a height of 9, and then accepts a height of 2
expected "" # #"\n"## ...", not "" #"\n"##""
:) rejects a non-numeric height of "foo"
:) rejects a non-numeric height of ""
this is what my code looks like :
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int n;
do
{
n = get_int("height: ");
}
while (n < 1 || n > 8);
for (int i = 0; i < n; i++)
{
for (int k = n-i-1; k > 0 ; k--)
{
printf(" ");
}
for (int j = 1; j <= i+1; j++)
{
printf("#");
}
{
printf(" ");
}
for (int l = 1; l <= i+1; l++)
{
printf("#");
}
printf("\n");
}
}
This is the output I get when I replace the white spaces with "." :
.....#..#
....##..##
...###..###
..####..####
.#####..#####
######..######
I can't figure out where I went wrong even after checking all the previous answers to this question because most of the time the issue was extra spaces after the right pyramid, but I don't have those.