0
#include <stdio.h>
#include <cs50.h>
int main(void){
int n;

do{
    printf("height: ");
    n=GetInt();
    if((n <= 0)||(n > 23)){
       printf("height: ");
       n=GetInt(); 
    }
} while((n < 1)||(n > 23));
int ws = n - 1;
for(int i = 0; i < n; i++){
    int rh = i+2;
    printf("%*s", ws, "");
    for(int k = 0; k < rh; k++){
        printf("#");
    }
    printf("\n");
    ws--;
}
return 1;
}

Mario problem when I do check50 terminal returns

Uploading........................................................................................................................ Unexpected end of input

Also when I do ./mario it works fine

1
  • Can't provide a solution, but I get exactly the same problem with the Mario app. I've made loads of changes to my code to see if there is something it doesn't like, but I still get the same error.
    – cyberspy
    Commented Jun 13, 2016 at 19:49

2 Answers 2

1

There are currently some timing issues with the servers at the moment and it is being looked into.

Having said that, while it looks like your program is running fine, it will always fail check50 because of the last line:

return 1;

If the servers weren't timing out, you would have seen an error reflecting this. The industry standard for return codes is this: when a program completes successfully, it should return 0. Any number other than 0 is expected to be an error code. (This can be confusing because when a function returns a boolean or bool, 0 is treated as false. Sort of contradictory.)

Next, a smaller problem. Your code rejects 0, which is a valid height.

Finally, an efficiency issue. The if() block in the do/while loop is redundant and completely unnecessary. You can remove it and the code will behave exactly the same, just a little more efficiently. I'll leave it to you to figure out why. ;-)

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

0

Because of the way CS50 checks problems, sometimes the 'Check50' app is unavailable because it is overloaded. This is not your fault.

Usually you have to wait a few minutes and try again. I had this happen earlier to me with my mario problem set.

Not sure what the staff will do to fix this, but it's a persistent issue if you look up 'check50' errors.

FYI this is a repeat issue

You must log in to answer this question.

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