1 1988-03-07
7305
代碼:
#includeint f[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; bool leap_year(int n) { if(n%4==0&&n%100!=0||n%4==0&&n%400==0) return true; else return false; } int DAY(int year,int month,int day) { int i,sum=0; for(i=1;i 2&&leap_year(year)) return sum+1; else return sum; } int main() { int T,year,month,day,i,sum; scanf("%d",&T); while(T--) { scanf("%d-%d-%d",&year,&month,&day); if(month==2&&day==29&&!leap_year(year+20)) { printf("-1\n"); continue; } sum=0; for(i=1;i<=19;++i) { if(leap_year(year+i)) sum+=366; else sum+=365; } if(leap_year(year)) sum=sum+(366-DAY(year,month,day)); else sum=sum+(365-DAY(year,month,day)); sum+=DAY(year+20,month,day); printf("%d\n",sum); } return 0; }
閏年並不都是每四年一潤:【 四年一潤,百年不潤,四百年再潤】
例:1980是閏年,1900並不是閏年