1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#include<iostream>
using namespace std;
int days(int a,int b,int c)
{
int day = 0;
switch(b-1)
{
case 12:day += 31;
case 11:day += 30;
case 10:day += 31;
case 9:day += 30;
case 8:day += 31;
case 7:day += 31;
case 6:day += 30;
case 5:day += 31;
case 4:day += 30;
case 3:day += 31;
case 2:day += 30;
case 1:day += 31;break;
}
day+=c;
if(a%400==0||a%4==0&&a%100!=0)
if(b>2) day++;
return day;
}
int main()
{
int a,b,c,x,y,z,day1,day2,res;
cin>>a>>b>>c;
cin>>x>>y>>z;
day1 = days(a,b,c);
day2 = days(x,y,z);
cout<<"day1 = "<<day1<<" day2 = "<<day2<<endl;
if(a==x)
res = day2-day1;
else
{
res = (365-day1)+day2+365*(x-a-1);
for(a;a<x;a++)
if(a%400==0||a%4==0&&a%100!=0)
res++;
}
res++;
cout<<"共离开了:"<<res;
return 0;
}
|