题目链接:http://poj.org/problem?id=2080
题目不是很难,也没什么说的,直接看代码吧:
#include<iostream>
#include<stdio.h>
using namespace std;
int year(int m)
{
if(m % 4 == 0 && m % 100 != 0 || m % 400 == 0)
return 1;
else
return 0;
}
int main()
{
int n,i,j,years[2] = {365,366};
int m1[2][12]={31,28,31,30,31,30,31,31,30,31,30,31,31,29,31,30,31,30,31,31,30,31,30,31};
char week[7][10] = {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
while(1)
{
scanf("%d",&n);
int x = n;
if(n == -1) break;
else
{
for(i = 2000;n >= years[year(i)];i++)
n -= years[year(i)];
for(j = 0;n >= m1[year(i)][j];j++)
n -= m1[year(i)][j];
printf("%d-%02d-%02d %s\n",i,j+1,n+1,week[x % 7]);
}
}
return 0;
}
标签:return,int,31,30,years,POJ,year,Calendar,2080 From: https://blog.51cto.com/u_16131191/6356135