#include<bits/stdc++.h>usingnamespace std;structnode{int year;int month;int day;}p;int f[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};char*weekday[10]={"Eight","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};boolisleap(structnode p){if((p.year %4==0&& p.year %100!=0)|| p.year %400==0){return1;}else{return0;}}intmain(){
p.year =2012;scanf("%d%d",&p.month,&p.day);if(isleap(p)){
f[2]=29;}else f[2]=28;int sum =0;//记录相隔的天数 for(int i =4; i <= p.month;++i){if(i != p.month && i ==4){
sum = sum + f[i]-12;}if(i == p.month && i !=4){
sum = sum + p.day;}if(i == p.month && i ==4){
sum = sum + p.day -12;}if(i != p.month && i !=4){
sum = sum + f[i];}}//printf("%d", sum);int add =4+ sum %7;if(add >7) add = add %7;printf("%s", weekday[add]);return0;}
某日期x天后的日期:
#include<bits/stdc++.h>usingnamespace std;structnode{int year;int month;int day;}p;int f[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};boolisleap(structnode p){if((p.year %4==0&& p.year %100!=0)|| p.year %400==0){return1;}else{return0;}}intmain(){int n;while(scanf("%d%d",&p.year,&n)!=EOF){if(isleap(p)){
f[2]=29;}else f[2]=28;//必须改回来int d =0;for(int i =1; i <=12;++i){
d = n;
n = n - f[i];if(n <=0){
p.month = i;
p.day = d;break;}}printf("%d-%02d-%02d\n", p.year, p.month, p.day);}return0;}