#include<stdio.h>
void month_nm(struct date day);
void tomorrow(struct date day);
int run(struct date day);
struct date
{
int day;
int month;
int year;
};
void main()
{
struct date day;
int a;
printf("\n以数字形式输入日期(年月日)\n");
printf("\n输入年(1900-2005):");
scanf("%d",&day.year);
fflush(stdin);
printf("\n输入月:");
scanf("%d",&day.month);
printf("\n输入日: ");
scanf("%d",&day.day);
printf("\n今天日期是:");
if((day.year>=1900)&&(day.year<=2005))
{ printf("%d年",day.year);
a=run(day);
}
else
printf("\n请输入的无效哦?");
if((day.month>=1)&&(day.month<=12))
{month_nm(day);
}
else
printf("\n请输入的无效哦?");
if((day.month==1||day.month==3||day.month==5||day.month==7||day.month==8||day.month==10||day.month==12)&&(day.day>=1&&day.day<=31))
printf("%d日",day.day);
else if ((day.month==4||day.month==6||day.month==9||day.month==11)&&(day.day>=1&&day.day<=30))
printf("%d日",day.day);
else if((day.month==2)&&(day.day>=1&&day.day<=28+a))
printf("%d日",day.day);
printf("\n明天日期是:");
tomorrow(day);
printf("\n");
}
void month_nm(struct date day)
{
switch(day.month)
{
case 1:printf("一月");break;
case 2:printf("二月");break;
case 3:printf("三月");break;
case 4:printf("四月");break;
case 5:printf("五月");break;
case 6:printf("六月");break;
case 7:printf("七月");break;
case 8:printf("八月");break;
case 9:printf("九月");break;
case 10:printf("十月");break;
case 11:printf("十一月");break;
case 12:printf("十二月");break;
}
}
int run(struct date day)
{int b;
if((day.year%4==0)&&(day.year%100!=0)||(day.year%400==0))
b=1;
else
b=0;
return b;
}
void tomorrow(struct date day)
{
struct date tomorrow;
if((day.month==1||day.month==3||day.month==5||day.month==7||day.month==8||day.month==10||day.month==12)&&(day.day<31))
{
tomorrow.day=day.day+1;
tomorrow.month=day.month;
tomorrow.year=day.year;
}
else if ((day.month==4||day.month==6||day.month==9||day.month==11)&&(day.day<30))
{
tomorrow.day=day.day+1;
tomorrow.month=day.month;
tomorrow.year=day.year;
}
else if((day.month==2)&&(day.day<(28+run(day))))
{
tomorrow.day=day.day+1;
tomorrow.month=day.month;
tomorrow.year=day.year;
}
else
{
tomorrow.month=day.month+1;
tomorrow.day=1;
tomorrow.year=day.year;
}
if(tomorrow.month>=12)
{
tomorrow.year=day.year+1;
tomorrow.month=1;
tomorrow.day=1;
}
printf("%d年",tomorrow.year);
printf("%d月",tomorrow.month);
printf("%d日",tomorrow.day);
}