(4.4)--4.4Multi-waysBranchanditsimpleme.pdf
《(4.4)--4.4Multi-waysBranchanditsimpleme.pdf》由会员分享,可在线阅读,更多相关《(4.4)--4.4Multi-waysBranchanditsimpleme.pdf(8页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、Multi-ways Branch and its implementationMulti-ways Branch and its implementation4.4In fact,there are someproblems with more than twopossible solutions,which are themulti-waysbranchproblems.For this kind of problem,youcan directly use the if or if.elsestatements to solve the problemsthrough multiple
2、judgments.However:The programwill be less readable and error-prone because of too many levelsof nesting when using if.elsestatements to deal with multi-branchproblems.C+alsoprovides the switch statement forthis kind of problem.Multi-ways Branch and its implementation4.4The form of the switch stateme
3、nt is:switch()case:break;case:break;case:break;default:Multi-ways Branch and its implementation4.4testtestconditionconditionconstant constant expressionexpression1 1constant constant expressionexpression2 2 constant constant expressionNexpressionNdefaultdefaultbranch statementbranch statement1 1bran
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 4.4 Multi waysBranchanditsimpleme
限制150内