2001年1月1日是星期六,给定一个整数n,判断n天后是哪年哪月哪天,星期几
# include<iostream>
using namespace std;
int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int y = 2000;
int m = 1, d = 1, week = 6;
int n;
bool is_run(int x)
{
if(x%4 == 0 && x%100!=0 || x%400 == 0) return true;
return false;
}
int main()
{
cin>>n;
for(int i = 1; i<=n; i++)
{
week+=1;
if(week>7) week = 1;
d+=1;
int tmp = month[m];
if(is_run(y)&&m == 2) tmp+=1;
if(d>tmp)
{
d = 1;
m++;
if(m>12)
{
m = 1;
y++;
}
}
}
printf("%d/%d/%d %d\n",y,m,d,week);
}