0

I submit pset1 Mario (less), and my code works correctly but in cs50.me showing that I have only 53% scores even though that my code work correctly.

#include <cs50.h>
#include <stdio.h>
int height,t,i,s,imake;   
int main(void)
{         
    do
   { 
    height = get_int("Height: ");
   }
    while(height <= 0 || height > 8);
  for(i=0;i<height;i++)
  {
       for(s=0;s<=i;s++)
        {
            printf("#");
        }
        for(t=0;t<height-i;t++)
        {
            printf(" ");
        }                
        printf("\n");
   }
 } 
1
  • Don't declare global variables unless you don't need them! Try to avoid those. – Linux Geek Sep 1 '19 at 22:46
2

Sorry to burst your bubble, but this code doesn't work correctly. It prints a left-justified pyramid. The pyramid is supposed to be right-justified. It prints spaces after the hash marks. They should be printed first. You could replace the space with an x in the print statement to see what's happening.

Is it possible you submitted an earlier version of your code?

You're probably also losing points on style - specifically indentation consistency.

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

0

Just to add to this - the same way you submit your code you can check before you submit! You will only need to wait about a minute to see how it scores. So as it was with Mario - to submit you typed submit50 cs50/problems/2019/x/mario/less in your console to submit, you need to type check50 cs50/problems/2019/x/mario/less to get the scores before you even submit - it runs the same check as it would after submission.

You can also use style50 mario.c to see if your code will pass the styling part of the checks.

Hope this makes sense.

Cheers

You must log in to answer this question.

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