文章
6
粉丝
553
获赞
11
访问
40.7k
#include <stdio.h>
int main(){
int y,m,d;
//init other month
int month[12]={31,0,31,30,31,30,31,31,30,31,30,31};
while(~scanf("%d %d %d",&y,&m,&d)){
int sum=0;
//init Feb.
if(y%4==0&&y%100!=0||y%400==0) month[1]=29;
else month[1]=28;
//Filter
if(y<1||m<1||m>12||d>month[m-1]||d<1){
printf("Input error!\n");
continue;
}
//calc day
for(int i=0;i<m-1;i++){
sum+=month[i];
}
sum+=d;
printf("%d\n",sum);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发