#include
//#include
struct date
{
int year;
int month;
int day;
};
void main()
{
void cf(struct date *p);
struct date s1,*p;
printf("请输入今天的日期: ");
while(scanf("%d %d %d",&s1.year,&s1.month,&s1.day))
{p=&s1;
cf(p);
}
//system("pause");
}
void cf(struct date *p)
{
struct date s2;
s2.day=p->day;
s2.month=p->month;
s2.year=p->year;
switch(s2.month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
if(s2.day==31)
{
++s2.month;
s2.day=1;
}
else
{++s2.day;}
break;
case 12:
if(s2.day=31)
{
++s2.year;
s2.day=1;
s2.month=1;
}
else
{++s2.day;}
break;
case 4:
case 6:
case 9:
case 11:
if(s2.day==30)
{
++s2.month;
s2.day=1;
}
else
{++s2.day;}
break;
case 2:
if(((s2.year)%4==0)&&((s2.year)%100!=0)||((s2.year)%400==0))
{
if(s2.day==29)
{
++s2.month;
s2.day=1;
}
else
{++s2.day;}
}
else
{
if(s2.day==28)
{
++s2.month;
s2.day=1;
}
else
{++s2.day;}
}
break;
}
printf("输出新的日期:%d %d %d\n",s2.year,s2.month,s2.day);
}
//我测试了几个数据,应该没错
//没有添加输入数据是否合理的判断程序 例如2014 4 56,2014 2 29
//判断情况复杂,用switch