#include<stdio.h>
int main(){
int month,year;
printf("输入月份:");
scanf("%d",&month);
printf("输入年份:");
scanf("%d",&year);
/*switch(month){
case 1:printf("31");break;
case 2:printf("28");break;
case 3:printf("31");break;
case 4:printf("30");break;
case 5:printf("31");break;
case 6:printf("30");break;
case 7:printf("31");break;
case 8:printf("31");break;
case 9:printf("30");break;
case 10:printf("31");break;
case 11:printf("30");break;
case 12:printf("31");break;
}*/
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
printf("31");break;
case 2:
{
if(year%4==0 && year%100!=0 || year%400==0)
printf("29");
else
printf("28");
}
break;
case 4:
case 6:
case 9:
case 11:
printf("30");break;
default:printf("error!\n");
}
return 0;
}
C语言。。。。。。SWITCH
最新推荐文章于 2024-09-02 16:35:28 发布