-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path2420.txt
More file actions
66 lines (62 loc) · 1.16 KB
/
2420.txt
File metadata and controls
66 lines (62 loc) · 1.16 KB
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
#include <iostream>
#include <vector>
#include<iomanip>
#include<string>
#include<algorithm>
using namespace std;
struct calendar
{
int year;
int month;
int day;
}ss;
vector <calendar> v;
int main()
{
bool f(int n);
int i,j,k,m,n,h=0;
for(i=2000;i<=9999;i++)
{
ss.year=i;
for(j=1;j<=12;j++)
{
ss.month=j;
if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
h=31;
else if(f(i)==true&&j==2)
h=29;
else if(f(i)==false&&j==2)
h=28;
else
h=30;
for(m=1;m<=h;m++)
{
ss.day=m;
v.push_back(ss);
}
}
}
for(int n;cin>>n&&n!=-1;)
{
cout<<v[n].year<<"-"<<setfill('0')<<setw(2)<<v[n].month<<"-"<<setfill('0')<<setw(2)<<v[n].day<<" ";
switch(n%7)//setfill()中的是字符或者字符常量
{
case 0:cout<<"Saturday"<<endl;break;
case 1:cout<<"Sunday"<<endl;break;
case 2:cout<<"Monday"<<endl;break;
case 3:cout<<"Tuesday"<<endl;break;
case 4:cout<<"Wednesday"<<endl;break;
case 5:cout<<"Thursday"<<endl;break;
case 6:cout<<"Friday"<<endl;break;
}
}
return 0;
}
bool f(int n)
{
if(n%4==0&&n%100!=0||n%400==0)
return true;
else
return false;
}
这个竟然是超出内存限制。。