else从于它上面的,最接近的未配对的if语句配对
年月计算
#include<stdio.h>
int main()
{
int year,month,days;
printf("请输入年,月");
scanf("%d,%d",&year,&month);
switch(month)
{
case1;
case3;
case5;
case7;
case8;
case10;
case12;
days=31;
break;
case4:
case6:
case9:
case11:
days=30;
break;
case2:
if(year%400==0||year%4==0&&year%100%100!=0)
days=29;
else
days=28;
break;
}
printf("%d年%d月的天数是%d天\n",year,month,days);
return 0;
}