#include
int main()
{
int Y, M;
scanf("%d%d", &Y, &M);
if (Y > 0 && M >= 1 && M <= 12)//合法输入
{
if (Y % 4 == 0 && Y % 100 != 0 || Y % 400 == 0)
//闰年
{
switch (M)
{
case 1:3:5:7:8:10:12:
printf("%d", 31);
case 2:
printf("%d", 29);
case 4:6:9:11:
printf("%d", 30);
}
}
else if
{
switch (M)
{
case 1:3:5:7:8:10:12:
printf("%d", 31);
case 2:
printf("%d", 28);
case 4:6:9:11:
printf("%d", 30);
}
}
}
else if
{
printf("error");
}
}
case 1:3:5:7:8:10:12: 这样是不可以的
switch (M)
{
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
printf("%d", 31);
break;
case 2:
printf("%d", 29);
break;
default:
printf("%d", 30);
break;
}
14、18行不可以这样写,报错