源自:4-17 switch与if语句的应用
不知道哪儿有错
#include <stdio.h>
int main()
{
int n;
int year = 2008;
int month = 8;
int day = 8;
if( year%4 == 0)
{
switch(month)
{
case 1:n=day;
break;
case 2:n=31+day;
break;
case 3:n=31+28+day;
break;
case 4:n=31+28+31+day;
break;
case 5:n=31+28+31+30+day;
break;
case 6:n=31+28+31+30+31+day;
break;
case 7:n=31+28+31+30+31+30+day;
break;
case 8:n=31+28+31+30+31+30+day+31;
break;
case 9:n=31+28+31+30+31+30+day+31+31;
break;
case 10:n=31+28+31+30+31+30+day+31+31+30;
break;
case 11:n=31+28+31+30+31+30+day+31+31+30+31;
break;
case 12:n=31+28+31+30+31+30+day+31+31+30+31+30;
break;
}
}
else
{
switch(month)
{
case 1:n=day;
break;
case 2:n=31+day;
break;
case 3:n=31+29+day;
break;
case 4:n=31+29+31+day;
break;
case 5:n=31+29+31+30+day;
break;
case 6:n=31+29+31+30+31+day;
break;
case 7:n=31+29+31+30+31+30+day;
break;
case 8:n=31+29+31+30+31+30+day+31;
break;
case 9:n=31+29+31+30+31+30+day+31+31;
break;
case 10:n=31+29+31+30+31+30+day+31+31+30;
break;
case 11:n=31+29+31+30+31+30+day+31+31+30+31;
break;
case 12:n=31+29+31+30+31+30+day+31+31+30+31+30;
break;
}
}
printf("%d",n);
return 0;
}
提问者:慕尼黑2539677
2017-12-12 21:10