c/school/ch09_9-1.c · 552 字节 · 下载原文
#include <stdio.h>
typedef struct date{
int year,month,day;
}date;
/*
一三五七八十腊 三十一天永不差
8月18号
1~7 有多少天
+18
*/
int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
int res=0;
date d;
scanf("%d %d %d",&d.year,&d.month,&d.day);
// 统计[1,d.month)的天数
for(int i=1;i<d.month;i++)
res+=month[i];
res+=d.day;
// 判断平年和闰年
if(d.year%4==0&&d.year%100 || d.year%400==0)
res+=1;
printf("%d",res);
return 0;
}