#include <stdio.h>
int main(){
int month, year;
printf("请输入月份:");
scanf("%d", &month);
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
printf("这个月有31天\n");
break;
case 4:
case 6:
case 9:
case 11:
printf("这个月有30天\n");
break;
case 2:
printf("请输入年份:");
scanf("%d", &year);
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
printf("这个月有29天\n");
} else {
printf("这个月有28天\n");
}
break;
default:
printf("没有你要的月份\n");
}
return 0;
}
运行效果