- 7
- 0
- 约 56页
- 2016-12-14 发布于湖北
- 举报
Important Rule ! switch (expression) { case value1 : statement1; break; case value2 : statement2; break; …… default : statementX; break; } Must be int or char! 5.8用于多路选择的switch语句 注意! Example: switch (month) { case 1: printf(January\n); break; case 2: printf(February\n); break; case 3: printf(March\n); break; default: printf(Others\n); break; } printf(End); Assume month = 1, so … …this step will be executed. Later … …case is terminated here. Jump to … January _ January End _ 5.8用于多路选择的switch语句 Example: switch (month) { case 1: printf(January\n); break; case 2: printf(February\n); break; case 3: printf(March\n); break; default: printf(Others\n); break; } printf(End); …this step will be executed. Later … March _ March End _ Assume month = 3, so … …case is terminated here. Jump to … 5.8用于多路选择的switch语句 Example: switch (month) { case 1: printf(January\n); break; case 2: printf(February\n); break; case 3: printf(March\n); break; default: printf(Others\n); break; } printf(End); Now…what will happen if this break is taken out from the program? 5.8用于多路选择的switch语句 Example: switch (month) { case 1: printf(January\n); break; case 2: printf(February\n); case 3: printf(March\n); break; default: printf(Others\n); break; } printf(End); No more ! 5.8用于多路选择的switch语句 Example: switch (month) { case 1: printf(January\n); break; case 2: printf(February\n); case 3: printf(March\n); break; default: printf(Others\n); break; } printf(End); …this step will be executed. Later … February _ March _ Assume month = 2, so … …case is terminated here. Jump to … End _ …execution continues. Thus, this step is executed . So … 5.8用于多路选择的switch语句 Example: switch (month) { case
您可能关注的文档
- 6.5宇宙航行赵君璞概论.ppt
- 第六章、原子吸收课题.ppt
- cs3000构成及使用方法讲述.ppt
- 第六章:定时计数器B课题.ppt
- 04核酸化学分析.ppt
- 6.8二重积分的计算概论.ppt
- 第六章:人体生命活动的调节__复习课题.ppt
- 第六章_离子聚合课题.ppt
- 第六章_微扰理论简介课题.ppt
- C语言CHP1讲述.ppt
- 小区绿化施工协议书.docx
- 墙面施工协议书.docx
- 1 古诗二首(课件)--2025-2026学年统编版语文二年级下册.pptx
- (2026春新版)部编版八年级道德与法治下册《3.1《公民基本权利》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《4.3《依法履行义务》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.2《按劳分配为主体、多种分配方式并存》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.1《公有制为主体、多种所有制经济共同发展》PPT课件.pptx
- 初三教学管理交流发言稿.docx
- 小学生课外阅读总结.docx
- 餐饮门店夜经济运营的社会责任报告(夜间贡献)撰写流程试题库及答案.doc
原创力文档

文档评论(0)