问题十三:按照气象划分法,通常以阳历3~5月为春季,6~8月为夏季,9~11月为秋季,12月~来年2月为冬季。使用switch结构编写函数根据月份输出对应的季节。
2013-04-05 18:41
429 查看
/***************************************************************
C语言
AUTHOR:liuyongshui
问题来源:http://blog.csdn.net/sxhelijian/article/details/8620846
***************************************************************/
/*
问题十三:按照气象划分法,通常以阳历3~5月为春季,
6~8月为夏季,9~11月为秋季,12月~来年2月为冬季。
使用switch结构编写函数根据月份输出对应的季节。
*/
#include <stdio.h>
void season(int m); //原函数season申明
int main()
{
int month;
printf("请输入月份:");
scanf("%d", &month);
season(month);
return 0;
}
// 函数的定义
void season(int m)
{
switch(m)
{
case 3:
case 4:
case 5:
printf("您输入的月份%d在春季\n", m);
break;
case 6:
case 7:
case 8:
printf("您输入的月份%d在夏季\n", m);
break;
case 9:
case 10:
case 11:
printf("您输入的月份%d在秋季\n", m);
break;
case 12:
case 1:
case 2:
printf("您输入的月份%d在冬季\n", m);
break;
default:
printf("您输入的数字不在0-12月份内!");
}
}
C语言
AUTHOR:liuyongshui
问题来源:http://blog.csdn.net/sxhelijian/article/details/8620846
***************************************************************/
/*
问题十三:按照气象划分法,通常以阳历3~5月为春季,
6~8月为夏季,9~11月为秋季,12月~来年2月为冬季。
使用switch结构编写函数根据月份输出对应的季节。
*/
#include <stdio.h>
void season(int m); //原函数season申明
int main()
{
int month;
printf("请输入月份:");
scanf("%d", &month);
season(month);
return 0;
}
// 函数的定义
void season(int m)
{
switch(m)
{
case 3:
case 4:
case 5:
printf("您输入的月份%d在春季\n", m);
break;
case 6:
case 7:
case 8:
printf("您输入的月份%d在夏季\n", m);
break;
case 9:
case 10:
case 11:
printf("您输入的月份%d在秋季\n", m);
break;
case 12:
case 1:
case 2:
printf("您输入的月份%d在冬季\n", m);
break;
default:
printf("您输入的数字不在0-12月份内!");
}
}
相关文章推荐
- 第一周:项目1 使用switch结构编写函数根据月份输出对应的季节
- 1-3 用switch结构编写函数根据月份输出对应的季节
- 根据用指定的月份,打印该月所属的季节(switch)3,4,5 春季 6,7,8 为夏季 9,10,11 秋季 12,1,2冬季
- 根据用指定的月份,打印该月所属的季节(if else)3,4,5 春季 6,7,8 为夏季 9,10,11 秋季 12,1,2为冬季
- switch结构--编写程序根据月份输出季节
- C语言宏定义##连接符和#符的使用(MFC就是靠##自动把消息和消息函数对应起来了,借助宏来减少switch case代码的编写量)
- switch语句应用输入月份输出对应季节举例
- java 根据月份,输出对应的季节,并输出至少描述该季节的成语和活动
- if语句应用输入月份输出对应季节举例
- makefile中使用变量及函数(3.注意.o输出路径问题)
- 根据用户的选择输出不同的结果--函数指针的使用
- 使用switch case语句来显示月份的对应天数
- 四叉树通常用来以紧凑的形式对数字图像进行编码(1.根据叶子节点构造四叉树 2.根据四叉树结构对加密图像进行解码 3.输出解码后的图像信息 )
- 作业3-5 输入五级制成绩(A-E),输出相应的百分制成绩(0-100)区间,要求使用 switch语句。例如,输入 A,输出 90-100。五级制成绩对应的百分制成绩区间为:A(90-100)、B(80-89)、C(70-79)、D(60-69)和 E(0-59)。
- Java中switch语句的练习(以判定月份所属季节为例),及其中的循环输入问题解析
- 编写程序 分别使用输入 输出 求平均值函数
- 使用switch语句编程,根据输入的年份判断是否为闰年,根据输入的月份判断这月有多少天
- 递归的使用:编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n。将输出结果保留到至少8个小数点。
- 根据用户输入年和月份值,输出对应月份的天数。
- 用户从键盘输入月份,使用switch语句输出该月份的天数