输入年份year、月份month,判断该月的天数。闰年:能被4整除但不能被100整除或者能被400整除的年份是闰年。
输入格式:
测试数据有多组,处理到文件尾。对于每组测试,输入两个整数,表示年份year和月份month。
输出格式:
对于每组测试,输出对应年月的天数。
输入样例:
2020 2
2020 4
输出样例:
29
30
#include<stdio.h>
int main()
{
int year, month;
while(scanf("%d %d",&year, &month)!=EOF){
switch (month)
{
case 2:if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
printf("29\n");
else
printf("28\n");
break;
case 4:
case 6:
case 9:
case 11:printf("30\n"); break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:printf("31\n"); break;
default:printf("ERROR\n"); break;
}
}
return 0;
}