-
Notifications
You must be signed in to change notification settings - Fork 0
/
h029.cpp
71 lines (64 loc) · 939 Bytes
/
h029.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
#include<iostream>
#include<fstream>
class week
{
private:
int year;
int month;
int day;
public:
week(std::ifstream& input)
{
input>>year;
input>>month;
input>>day;
}
void calc();
};
void main()
{
std::ifstream input;
input.open("input.txt");
int cases;
input>>cases;
for(int i=0; i<cases; i++)
{
week lf(input);
lf.calc();
}
}
void week::calc()
{
int D_day = 0;
for(int i = 1582; i< year; i++)//연도
{
D_day+=365;
if( (i%4==0) && ((i%100!=0)||(i%400==0)))//윤년일 경우
{
D_day++;
}
}
for(int i=1; i<month; i++)//월
{
if((i==1)||(i==3)||(i==5)||(i==7)||(i==8)||(i==10)||(i==12))
{
D_day+=31;
}
else if((i==4)||(i==6)||(i==9)||(i==11))
{
D_day+=30;
}
else
{
if( (year%4==0) && ((year%100!=0)||(year%400==0)))//윤년일 경우
{
D_day++;
}
D_day+=28;
}
}
D_day+=(day-1);//일
D_day+=5;//금요일 부터 시작했으므로
D_day%=7;
std::cout<<D_day<<std::endl;
}