
用整数1—12依次表示1-12月,由键盘输入一个月份数,输出对应的季节
用整数1—12依次表示1-12月,由键盘输入一个月份数,输出对应的季节(3-5月为春季,6-8月为夏季,9-11月为秋季,12-2月为冬季)。(要求用函数调用)...
用整数1—12依次表示1-12月,由键盘输入一个月份数,输出对应的季节(3-5月为春季,6-8月为夏季,9-11月为秋季,12-2月为冬季)。(要求用函数调用)
展开
1个回答
展开全部
#include <stdio.h>
void func(int month)
{
switch(month)
{
case 12:
case 1:
case 2:
printf("Winter");
break;
case 3:
case 4:
case 5:
printf("Spring");
break;
case 6:
case 7:
case 8:
printf("Summer");
break;
case 9:
case 10:
case 11:
printf("Autumn");
break;
default:
printf("Wrong month!");
}
}
void main()
{
int month;
printf("input the month:");
scanf("%d",&month);
func(month);
}
void func(int month)
{
switch(month)
{
case 12:
case 1:
case 2:
printf("Winter");
break;
case 3:
case 4:
case 5:
printf("Spring");
break;
case 6:
case 7:
case 8:
printf("Summer");
break;
case 9:
case 10:
case 11:
printf("Autumn");
break;
default:
printf("Wrong month!");
}
}
void main()
{
int month;
printf("input the month:");
scanf("%d",&month);
func(month);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询