日期
#include<bits/stdc++.h> using namespace std; int tans(char *s){ if(!strcmp(s,"January")){ return 1; }else if(!strcmp(s,"February")){ return 2; }else if(!strcmp(s,"March")){ return 3; }else if(!strcmp(s,"April")){ return 4; }else if(!strcmp(s,"May")){ return 5; }else if(!strcmp(s,"June")){ return 6; }else if(!strcmp(s,"July")){ return 7; }else if(!strcmp(s,"August")){ return 8; }else if(!strcmp(s,"September")){ return 9; }else if(!strcmp(s,"October")){ return 10; }else if(!strcmp(s,"November")){ return 11; }else if(!strcmp(s,"December")){ return 12; } } bool isleap(int year){ if(year%400==0) return 1; if(year%4==0&&year%100!=0) return 1; return 0; } int main(){ int t,cnt=0; char mm1[20],mm2[20]; int day1,day2,year1,year2,month1,month2; scanf("%d",&t); while(t--){ scanf("%s %d, %d",mm1,&day1,&year1); scanf("%s %d, %d",mm2,&day2,&year2); month1=tans(mm1); month2=tans(mm2); if(year2<year1){ swap(year1,year2); swap(month1,month2); swap(day1,day2); }else if(year1==year2&&month1>month2){ swap(month1,month2); swap(day1,day2); }else if(year1==year2&&month1==month2&&day1>day2){ swap(day1,day2); } // printf("1] %d %d %d\n",year1,month1,day1); // printf("2] %d %d %d\n",year2,month2,day2); int num2,num1,num; num2=year2/400+year2/4-year2/100; num1=(year1-1)/400+(year1-1)/4-(year1-1)/100; num=num2-num1; if(isleap(year2)){ if(month2==1||month2==2&&day2<29){ num--; // printf("%d+++++\n",num); } } if(isleap(year1)){ if(month1>=3){ num--; // printf("%d-----\n",num); } } printf("Case %d: %d\n",++cnt,num); } return 0; } /* 5 August 12, 2000 August 12, 2005 */
学学学 练练练 刷刷刷