- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
第四章 选择结构程序设计 教学目的:掌握选择结构的形式,掌握典型算法。 教学要求:掌握关系表达式和逻辑表达式以及在选择结构中的使用。学会把现实问题通过表达式的形式表示。 (补充)从数学而言,当y是正时,x+yx等价于y0,它们的逻辑结果都是true。但从计算机而言,当x与y的绝对值相差很大时,这个值就有可能是false #include stdio.h main() { double x=1e20,y=10; printf(%d, x+yx); getch(); } /* 输出是0 */ 例如:已知三角形的三条边求面积 程序 #include stdio.h #include math.h main ( ){ float a,b,c,s,area; printf(Side a=); scanf(%f,a); printf(Side b=); scanf(%f,b); printf(Side c=); scanf(%f,c); if (a+bca+cbb+ca){ s=0.5*(a+b+c); area=sqrt(s*(s-a)*(s-b)*(s-c)); printf(area=%6.2f\n,area); } else printf(“Sorry,reentry please.); getch(); } A code fragment is to be used to separate integer values into five ranges. For example: 0 .. 29, 30 .. 49, 50 .. 59, 60 .. 69, 70 .. 100. What is the fewest number of if .. else selection statements needed to do this? Note, all data presented will already have been validated to ensure they are in the range 0 ..100. break语句(中断语句) 语句形式:break; 作用:中止switch结构或循环结构的执行, 转去执行相应结构的下一条语句。 说明:break语句只能用于switch结构或者循 环结构之中。 switch statements 使用if语句嵌套层次太多,容易发生错误,因此在多分支结构中,通常使用switch语句 。 Suppose we had an integer variable j, and wanted to execute different statements depending on the value of j. Lets suppose we wanted to print j is one if j had value 1, j is two if j has the value 2, otherwise we want to print j is neither 1 nor 2. We could write the following code: if (j == 1) printf(“j is one”); else if (j == 2) printf(“ j is two”); else printf(“j is neither 1 nor 2”); OR we could use a switch statement. switch statement example switch (j) { case 1: printf(“ j is one”); break; case 2: printf(“ j is two”); break; default: printf(“j is neither 1 nor 2”); } When used in a switch statement , the break statement causes control to pass to the statement following the closing brace. switch statement switch语句的一般形式 switch (expr) { case constant1: statement1; break; ca
您可能关注的文档
最近下载
- 移动L1认证传输专业试题汇总(含答案).pdf VIP
- (新版)中移动传输专业L1认证考试复习题库-上(单选题汇总).docx VIP
- 计算机专业(基础综合)模拟试卷3(共456题).pdf VIP
- 项目编号szcg2007041645 项目名称2007年度深圳市储备土地管理.doc
- 离婚登记申请受理回执单民法典版(可直接打印).pdf VIP
- 人教五年级数学上册1.2.2 倍数是小数的实际问题和乘法验算 课时训练.doc VIP
- 光伏电站检修规程(行业标准).docx VIP
- (新版)中移动传输专业L1认证考试复习题库-下(多选题汇总).docx VIP
- 基于大概念的初中音乐单元整体教学设计探索.doc VIP
- 《企业经营数据分析》课件.ppt VIP
文档评论(0)