ios学习Day3xiawu
2024-10-15 02:35:11
switch
#include <stdio.h> int main(int argc, char * argv[])
{
int i;
scanf("%d",&i);
switch(i)
{
case :
{printf("春");
break;
}
case :
{
printf("夏");
break;
}
case :
{
printf("秋");
break;
} case :
{ printf("冬");
}
default:
break; }
}
多个case可以运行一个语句块
case中定义变量需要加{};
枚举类型(enum)
1
提高程序的可读性,本质是整形,用枚举类型代表整数常量;
enum Season {
spring,
summer,
autumn,
winter
}
//默认从零开始
enum Season aeason=0;
scanf("%d,&season");
switch(season)
{
case spring:
{
printf("spring");
}
case summer:
{
printf("spring");
}
case autumn:
{
printf("autumn");
]
}
#include <stdio.h>
enum Season {
spring=,
summer,
autumn,
winter
};
typedef enum Season myseason ;//为现有类型创建一个别名
int main(int argc, char * argv[])
{
//默认从零开始
myseason season=;
scanf("%d",&season);
switch(season)
{
case spring:
{ printf("spring");
break; }
case summer: {
printf("summer");
break;
}
case autumn:
{
printf("autumn");
break; }
case winter:
{
printf("winter");
break;
}
default:
{
printf("未知");
} }
}
最新文章
- C# 调用百度翻译Api
- tomcat组成及工作原理
- JavaScript之模块化编程
- JavaScriptの例
- Hadoop源代码导入Eclipse
- 3384/1750: [Usaco2004 Nov]Apple Catching 接苹果
- [Swift]LeetCode564. 寻找最近的回文数 | Find the Closest Palindrome
- Oracle :多表更新多个字段
- IIS下MySQL停止和启动的方法
- Hass.io: add-on Samba
- VuePress
- C#学习笔记(35)——事件做的登录案例
- 逻辑回归(logic regression)的分类梯度下降
- FireDAC 下的 Sqlite [1] - 前言
- linux 安装 vsftpd服务
- 测试用例Excel模板For Quality Center
- Android --------------------ActionBar 与 ViewPager 和 ActionTab 切换 的源代码实现
- Codeforces Round #303 (Div. 2) A. Toy Cars 水题
- makefile .phony targets
- Sort函数(C++)