#include "stdio.h"
void main()
{
int y,m,d,leap=0;
printf("2013914209\n");
printf("请输入年份和月份:");
scanf("%d,%d",&y,&m);
switch(m)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:d=31;break;
case 4:
case 6:
case 9:
case 11:d=30;break;
case 2:if(y%4==0&&y%100!=0||y%400==0)d=29,leap=1;
else d=28;break;
default:printf("ERROR!");
}
if(leap)
printf("%d is a leap year and the month has %d days.",y,d);
else
printf("%d is not a leap year and the month has %d days.",y,d);
}
心得:这个编程开可以输入年份月份查询天数。。