I have been getting an error from the check50 function for my Mario Less program. This is the reply from the check50 function. My codes work according to the specification and my own testings, so I'm confused as to why it's giving me this response.
:) mario.c exists.
:) mario.c compiles.
:) rejects a height of -1
:) handles a height of 0 correctly
:( handles a height of 1 correctly
expected "##\n", not "Height: 1\nxx\n"
:( handles a height of 2 correctly
expected " ##\n###\n", not "Height: 2\n xx..."
:( handles a height of 23 correctly
expected " ...", not "Height: 23\n ..."
:( rejects a height of 24, and then accepts a height of 2
expected " ##\n###\n", not "Height: 2\n xx..."
:) rejects a non-numeric height of "foo"
:) rejects a non-numeric height of ""
This is my code for Mario Less.
#include <stdio.h>
#include <cs50.h>
int height (void);
void pyramid (int h);
int main (void)
{
int he = height();
pyramid(he);
}
int height (void)
{
printf("Height of half pyramid?\nPlease enter a non negative integer that is no greater than 23.\n");
int x;
int h;
do
{
h = get_int();
x = h;
if ( x < 0 || x > 23)
{
printf("Please enter a non negative integer no greater than 23.\n");
}
}while (x < 0 || x > 23);
printf("Height: %i\n", x);
return (x);
}
void pyramid (int h)
{
int z = 0;
int x = 0;
int y = 0;
for (z = 1 ; z < h + 1 ; z ++)
{
for (y = z - 1 ; y < h - 1; y ++)
{
printf(" ");
}
for (x = 0 ; x < z+1; x ++)
{
printf("x");
}
printf("\n");
}
}
Any help would be appreciated! Thanks in advance