满意答案
bcabcdefg
2013.07.28
采纳率:49% 等级:12
已帮助:5373人
#include
enum season
{
spring = 1,
summer,
autumn,
winter,
};
season GetSeasonByMonth(char month)
{
if(month <= 3 && month>=1)
return spring;
else if(month <= 6 && month>=4)
return summer;
else if(month <= 9 && month>=7)
return autumn;
return winter;
}
int main(void)
{
printf("请输入月份:\n");
char m;
scanf("%c",&m);
season s = GetSeasonByMonth(m);
switch (s)
{
case spring:
printf("该月份在春季\n");
break;
case summer:
printf("该月份在夏季\n");
break;
case autumn:
printf("该月份在秋季\n");
break;
case winter:
printf("该月份在冬季\n");
break;
default:
break;
}
return 0;
}
11分享举报