解题思路:
注意事项:
参考代码:
#include<stdio.h>
struct numberofday{
int year;
int month;
int day;
} d;
const int r=30;
const int b=31;
int main(){
int t;
scanf("%i %i %i",&d.year,&d.month,&d.day);
if((d.year%4==0&&d.year%100!=0)||(d.year%400==0))
t=29;
else
t=28;//定义2月的天数//
int a=d.month;
switch(a){
case 1:d.day=d.day;break;
case 2:d.day=d.day+b;break;
case 3:d.day=d.day+b+t;break;
case 4:d.day=d.day+2*b+t;break;
case 5:d.day=d.day+2*b+r+t;break;
case 6:d.day=d.day+3*b+r+t;break;
case 7:d.day=d.day+3*b+2*r+t;break;
case 8:d.day=d.day+4*b+2*r+t;break;
case 9:d.day=d.day+5*b+2*r+t;break;
case 10:d.day=d.day+5*b+3*r+t;break;
case 11:d.day=d.day+6*b+3*r+t;break;
case 12:d.day=d.day+6*b+4*r+t;break;
} //不同月数天数不一样//
printf("%i",d.day);
return 0;
}
0.0分
0 人评分