1个回答
展开全部
#include <stdio.h>
int monthsize(int year,int month) {
int days;
if(month == 2) {
if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
return 29;
return 28;
}
switch(month) {
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10 :
case 12 :days = 31; break;
case 4 :
case 6 :
case 9 :
case 11 : days = 30; break;
}
return days;
}
int main() {
int year,month,day,days;
printf("年 月 日:");
while(scanf("%d%d%d",&year,&month,&day) == 3) {
days = monthsize(year,month);
if(days == day) {
if(month == 12) {
++year;
month = 1;
day = 1;
}
else ++month;
}
else ++day;
printf("第二天是:%d/%02d/%02d\n",year,month,day);
printf("年 月 日(q to quit):");
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询