Home > Back-end >  Why test platform don't agree with me
Why test platform don't agree with me

Time:09-29

#include
Int main ()
{
Int year, month, flag;
The scanf (" % d % d ", & amp; Year, & amp; The month);
If (year %==0 100 & amp; & Year& 400==0 | | year % 4==0 & amp; & 10 year %==0)
{
Flag=1;
}
The else
{
Flag=0;
}
The switch (month)
{
Case 1: the month=31; break;
Case 2: the month=28 + flag; break;
Case 3: the month=31; break;
Case 4: the month=30; break;
Case 5: the month=31; break;
Case 6: the month=30; break;
Case 7: the month=31; break;
Case 8: the month=31; break;
Case 9: the month=30; break;
Case 10: the month=31; break;
Case 11: the month=30; break;
Case 12: the month=31; break;
}
Printf (" % d ", month);
return 0;
}
But testing platform with this
# include & lt; stdio.h>

Int main ()
{
int year;
int month;

The scanf (" % d % d ", & amp; Year, & amp; The month);
The switch (month)
{
Case 1: {printf (" 31 "); break; }
Case 2:
{
If ((year % 4==0 & amp; & Year % 100! 400==0) | | year %=0) printf (" 29 ");
The else printf (" 28 ");
break;
}
Case 3: {printf (" 31 "); break; }
Case 4: {printf (" 30 "); break; }
Case 5: {printf (" 31 "); break; }
Case 6: {printf (" 30 "); break; }
Case 7: {printf (" 31 "); break; }
Case 8: {printf (" 31 "); break; }
Case 9: {printf (" 30 "); break; }
Case 10: {printf (" 31 "); break; }
Case 11: {printf (" 30 "); break; }
Case 12: {printf (" 31 "); break; }
}

return 0;

}

CodePudding user response:

Because the test scope of data requirements, the following this month mistyped does not have the output, but the sample you give the wrong month so there will be output, it is best to make a judgment after input,

CodePudding user response:

Printf for puts

CodePudding user response:

If (year %==0 100 & amp; & Year & amp; 400==0 | | year % 4==0 & amp; & 10 year %==0)
What is this judge???
To the somebody else that

CodePudding user response:

 # include 
Int main ()
{
Int year, month, flag, day;
The scanf (" % d % d ", & amp; Year, & amp; The month);
//if (year %==0 100 & amp; & Year& 400==0 | | year % 4==0 & amp; & 10 year %==0)
If (year %==0 400 | | (year % 4==0 & amp; & Year % 100!=0))
{
Flag=1;
}
The else
{
Flag=0;
}
The switch (month)
{
Case 1:
Case 3:
Case 5:
Case 7:
Case 8:
Case 10:
Case 12:
Day=31;
break;

Case 4:
Case 6:
Case 9:
Case 11:
Day=30;
break;

Case 2:
Day=28 + flag;
break;

Default:
break;
/*
Case 1: the month=31; break;
Case 2: the month=28 + flag; break;
Case 3: the month=31; break;
Case 4: the month=30; break;
Case 5: the month=31; break;
Case 6: the month=30; break;
Case 7: the month=31; break;
Case 8: the month=31; break;
Case 9: the month=30; break;
Case 10: the month=31; break;
Case 11: the month=30; break;
Case 12: the month=31; break;
*/
}
Printf (" % d ", month);
return 0;
}

For your reference ~
  • Related