Testing the code manually, the output seems ok. But then when I use check50 it fails with the inputs 2 and 23.
#include <stdio.h>
#include <cs50.h>
int main(void)
{
printf("Type the half-pyramid's heigths (between 1-23): ");
int height = get_int();
if (height < 0 || height > 23){
printf("\nThe maximum value must be 23.\nPlease type again: ");
height = get_int();
}
for (int i = 0; i < height; i++){
int hash = 0, space = 0;
int s = (height - i - 1);
while (space < s){
printf(" ");
space++;
}
while (hash <= i){
printf("#");
hash++;
}
printf(" ");
hash = 0, space = 0;
while (hash <= i){
printf("#");
hash++;
}
while (space < s){
printf(" ");
space++;
}
printf("\n");
}
}
Can anyone tell me what am I doing wrong?