第1个回答 2014-11-11
#include "stdio.h"
void main()
{
int year, month, day,maxday;
printf("请输入年月日:\n");
scanf("%d%d%d", &year, &month, &day);
if(year>=1900&&year<=2014)
printf("年份输入正确\n");
else
printf("年份输入错误\n");
if(month>=1&&month<=12)
printf("月份输入正确\n");
else
printf("月份输入错误\n");
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
maxday = 31;
break;
case 4:
case 6:
case 9:
case 11:
maxday = 30;
break;
case 2:
if (year%4==0&&year%100!=0||year%400==0)
maxday = 29;
else
maxday = 28;
break;
default:
break;
}
if (day<=maxday)
{
printf("日期输入正确\n");
}
else
printf("日期输入错误\n");
return;
}本回答被网友采纳