标签:
5
代码:
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int week[3005][15][35];
int month1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int month2[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
void count(){
int year=2011, month=11 ,day=11, ans=5;
week[year][month][day] = 5;
while(1){
if(year==3000)
break;
if(year % 400 ==0 || (year%4 == 0 && year % 100 != 0)){
day++;
if(day > month2[month])
{
month++;
day=1;
}
if(month > 12)
{
month=1;
year++;
}
ans++;
if(ans > 7)
ans=1;
week[year][month][day]=ans;
}
else {
day++;
if(day > month1[month])
{
month++;
day=1;
}
if(month > 12)
{
month=1;
year++;
}
ans++;
if(ans > 7)
ans=1;
week[year][month][day]=ans;
}
}
year=2011;
month=11;
day=11;
ans=5;
while(1){
if(year == 1598)
break;
if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
{
day--;
if(day <= 0){
month--;
if(month <= 0)
day = 31;
else
day = month2[month];
}
if(month <= 0)
{
month=12;
year--;
}
ans--;
if(ans <= 0)
ans=7;
week[year][month][day]=ans;
}
else {
day--;
if(day<=0){
month--;
if(month <= 0)
day=31;
else
day = month1[month];
}
if(month <= 0)
{
month=12;
year--;
}
ans--;
if(ans <= 0)
ans=7;
week[year][month][day]=ans;
}
}
}
int main()
{
count();
int y,m,d;
while(~scanf("%d%d%d",&y,&m,&d))
cout<<week[y][m][d]<<endl;
return 0;
}
标签:
原文地址:http://blog.csdn.net/u012965373/article/details/44957611