a263.
日期差幾天
--
板橋高中練習題
| From: [1.161.233.141] |
發表日期
:
2018-05-22 17:31
#include<stdio.h>
int main (){
int a,b,c,y,m,d;
while(scanf("%d %d %d",&a,&b,&c)!=EOF){
scanf("%d %d %d",&y,&m,&d);
if(a>y){
a=a+y-(y=a);
b=b+m-(m=b);
c=c+d-(d=c);
}
else if(a==y&&b>m){
b=b+m-(m=b);
c=c+d-(d=c);
}
else if(a==y&&b==m&&c>d){
c=c+d-(d=c);
}
int ary[]={0,31,0,31,30,31,30,31,31,30,31,30,31};
int i,num=0,days=0;
if(a!=y||b!=m){
num=(y-a)*12+m-b;
for(i=0;i<num;i++){
if(a%100==0&&a%400!=0||a%4!=0)ary[2]=28;
else ary[2]=29;
days+=ary[b++];
if(b>12){
b=1;
a++;
}
}
}
days+=(d-c);
printf("%d\n",days);
}
return 0;
}