-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHDU_2005.cpp
More file actions
46 lines (45 loc) · 725 Bytes
/
HDU_2005.cpp
File metadata and controls
46 lines (45 loc) · 725 Bytes
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>
#include <string>
using namespace std;
int main()
{
string st;
int month1[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int month2[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
while (cin>>st)
{
int arr[3]={0};
int begain=0,end=0,i=0,days=0;
st += "/";
while (i<3)
{
end = st.find('/',begain);
int pow = 1;
for (int j=end-1;j>=begain;j--)
{
arr[i] += (st[j]-'0')*pow;
pow = pow*10;
}
begain = end + 1;
i++;
}
if (arr[0]%4 == 0)
{
for (int j=0;j<arr[1]-1;j++)
{
days += month2[j];
}
days += arr[2];
}
else
{
for (int j=0;j<arr[1]-1;j++)
{
days += month1[j];
}
days += arr[2];
}
cout << days << endl;
}
return 0;
}