-
Notifications
You must be signed in to change notification settings - Fork 0
/
4WeekUseDaGap.cpp
93 lines (90 loc) · 1.47 KB
/
4WeekUseDaGap.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include<iostream>
#include<cstdlib>//abs
#include<cstring>
using namespace std;
#define ISLEAP(x) x%100!=0&&x%4==0||x%400==0?1:0
//pay attention to regular,no comma;
int DayOfMonth[13][2]=
{
0,0,
31,31,
28,29,
31,31,
30,30,
31,31,
30,30,
31,31,
31,31,
30,30,
31,31,
30,30,
31,31
};
char month[13][20]=
{
" ",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
char week[7][20]=
{
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};
// Time difference
int TimeDiff(int day,int mo,int ye)
{
int days=0;
for(int i=1000; i<ye; i++)
{
if( ISLEAP(i))
days+=366;
else
days+=365;
}
int is_leap=ISLEAP(ye);
for(int j=1; j<mo; j++)
{
days+=DayOfMonth[j][is_leap];
}
days+=day;
return days;
}
int main()
{
int day=0,year=0,m=0,w=0;
char mon[20];
while(cin>>day)
{
cin>>mon>>year;
for(int i=1; i<13; i++)
{
if(strcmp(mon,month[i])==0)
{
m=i;
break;
}
}
//cout<<abs(TimeDiff(15,11,2001)-TimeDiff(14,11,2001));
int diff=TimeDiff(day,m,year)-TimeDiff(25,6,2017);
//cout<<diff;
int w=(diff%7+7)%7;
cout<<week[w]<<endl;
}
return 0;
}