1 #include <iostream>
2 #include <cstdio>
3 #include <cmath>
4 using namespace std;
5
6 int tianxia[2][12]={
7 {31,28,31,30,31,30,31,31,30,31,30,31},
8 {31,29,31,30,31,30,31,31,30,31,30,31}
9 };
10
11 int isPrime(int year){
12 if(year%4==0&&year%100!=0 || year%400==0)
13 return 1;
14 else
15 return 0;
16 }
17
18 int main()
19 {
20 int a,b;
21 scanf("%d%d",&a,&b);
22 if(a<b)
23 a^=b;b^=a;a^=b;
24 ///经过上边的操作后,日期a将大于日期b
25 int yeara=a/10000;
26 int moutha=(a%10000)/100;
27 int daya=(a%100);
28
29 int yearb=b/10000;
30 int mouthb=(b%10000)/100;
31 int dayb=(b%100);
32
33 int day1,day2,day3;
34 day1=day2=day3=0;
35
36 for(int i=0;i<moutha-1;i++){
37 printf("%d : %d\n",i+1,tianxia[isPrime(yeara)][i]);
38 day1+=tianxia[isPrime(yeara)][i];
39 }
40 day1+=daya-1;
41
42 for(int i=0;i<mouthb-1;i++){
43 printf("%d : %d\n",i+1,tianxia[isPrime(yearb)][i]);
44 day2+=tianxia[isPrime(yearb)][i];
45 }
46 day2+=dayb-1;
47
48 for(int i=yearb;i<yeara;i++){
49 if(isPrime(i)==0)day3+=365;
50 else day3+=366;
51 }
52 int ans = day3+day1-day2;
53 printf("The ans is :%d %d %d %d",ans,day1,day2,day3);
54 return 0;
55 }