//输入某年某月 输出该月有几天
#include <>
int main() {
int year, month, days; //定义year,month,days
printf("输入某年某月:");
scanf("%d %d", &year, &month); //输入年份,月份
switch (month) { //运用switch...case...用法
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;
case 2:
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) //判断平年还是闰年
days = 29;
else
days = 28;
break;
}
printf("%d年的%d月有%d天", year, month, days); //输出该月的天数
}