#include<stdio.h>
typedef struct date{
int year;
int month;
int day;
}date;
int days_format(date d)
{
switch(d.month){
case 2:return d.year%(d.year%100?4:400)?28:29;
case 4:case 6:case 9:case 11:
return 30;
default:return 31;
}
}
void prior(date &d)
{
if(d.day>1)d.day--;
else{
if(d.month>1){
d.month--;
d.day=days_format(d);
}
else {
d.year--;
d.month=12;
d.day=days_format(d);
}
}
}
int main(void)
{
date d;
int j,t;
char a[7][3]={"一","二","三","四","五","六","日"};
printf("请输入日期 按格式 年 月 日 星期几 :如:2015 4 1 3\n");
scanf("%d%d%d%d",&d.year,&d.month,&d.day,&j);
printf("请输入往前的天数");
scanf("%d",&t);
printf("%d年%d月%d日是星期%s,",d.year,d.month,d.day,a[j-1]);
for(int i=0;i<t;i++){
prior(d);
j=(j+5)%7+1;
}
printf("则往前%d天是%d年%d月%d日星期%s ",t,d.year,d.month,d.day,a[j-1]);
}