文章
21
粉丝
76
获赞
1
访问
14.6k
#include<stdio.h>
#include<stdlib.h>
int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int day(int n){
int year = n/10000;
int month = n/10000/100;
int da = n/10000%100;
days[2] = (year%4==0&&year%100!=0 || year%400==0?29:28);
while(month--){
da+=days[month];
}
while(year--){
da+=(year%4==0&&year%100!=0 || year%400==0?366:365);
}
return da;
}
int main(void){
int dateone,datetwo;
while(scanf("%d%d",&dateone,&datetwo) !=EOF){
int d = abs(day(dateone)-day(datetwo))+1;
printf("%d\n",d);
}
...
登录后发布评论
月份计算写错了吧