输入今天的日期,求明天的日期,出错了,不知怎么回事
struct date{
int year;
int month;
int day;
};
void main()
{
void cf(struct date *p);
struct date s1,*p;
printf("请输入今天的日期: ");
scanf("%d %d %d",&s1.year,&s1.month,&s1.day);
p=&s1;
cf(p);
}
void cf(struct date *p)
{
struct date s2;
if(p->day<28)
s2.year=p->year;
s2.month=p->month;
s2.day=p->day+1;
else if(p->day==28)
if(p->year%4==0&&p->year%100!=0||p->year%400==0)
s2.year=p->year;
s2.month=p->month;
s2.day=p->day+1;
else
s2.year=p->year;
if(p->month==2)
s2.month=3;
s2.day=1;
else
s2.month=p->month;
s2.day=p->day+1;
else if(p->day==29)
if(p->year%4==0&&p->year%100!=0||p->year%400==0)
if(p->month==2)
s2.month=3;
s2.day=1;
else
s2.year=p->year;
s2.month=p->month;
s2.day=p->day+1;
else if(p->day==30)
if(p->month==1||3||5||7||8||10||12)
s2.year=p->year;
s2.month=p->month;
s2.day=p->day+1;
else
s2.year=p->year;
s2.month=p->month+1;
s2.day=1;
else
if(p->month==12)
s2.year=p->year+1;
else
s2.year=p->year;
s2.month=p->month+1;
s2.day=1;
printf("输出新的日期:%d %d %d\n",s2.year,s2.month,s2.day);
}