标签:
#include<stdio.h> //2001 1 1 Saturday char week[7][10] = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday","Thursday","Friday"}; int year[2] ={365, 366}; int month[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}}; int type(int year) { if(year%4 != 0 || (year%100 == 0 && year%400 !=0 )) return 0; else return 1; } int main() { int days, dayofweek; int i, j; while(scanf("%d", &days) && days != -1) { dayofweek = days%7; for(i = 2000; days >year[type(i)]; i++) days -= year[type(i)]; for(j = 0; days > month[type(i)][j]; j++) days -= month[type(i)][j]; printf("%d-%02d-%02d %s\n", i , j+1, days+1, week[dayofweek]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/superkrissV/p/4472464.html