解题思路:
注意事项:
参考代码:
#include<stdio.h>
struct data
{
int year;
int month;
int day;
}s;
int main()
{int t=0;
scanf("%d%d%d",&s.year ,&s.month ,&s.day);
if(s.year %4==0&&s.year %100!=0||s.year %400==0)t=1;
switch(s.month )
{
case 1:break;
case 2:s.day =s.day +31;break;
case 3:if(t) s.day =s.day +60;
else s.day =s.day +59;break;
case 4:if(t) s.day =s.day +91;
else s.day =s.day +91-1;break;
case 5:if(t) s.day =s.day +121;
else s.day =s.day +121-1;break;
case 6:if(t) s.day =s.day +152;
else s.day =s.day +152-1;break;
case 7:if(t) s.day =s.day +182;
else s.day =s.day +182-1;break;
case 8:if(t) s.day =s.day +213;
else s.day =s.day +213-1;break;
case 9:if(t) s.day =s.day +244;
else s.day =s.day +244-1;break;
case 10:if(t) s.day =s.day +274;
else s.day =s.day +274-1;break;
case 11:if(t) s.day =s.day +305;
else s.day =s.day +305-1;break;
case 12:if(t) s.day =s.day +335;
else s.day =s.day +335-1;break;
default:printf("error!\n");return 0;
}
printf("%d\n",s.day );
return 0;
}
0.0分
0 人评分