- 1
- 0
- 约3.13千字
- 约 16页
- 2017-12-26 发布于河北
- 举报
chapter6--C程序设计(英文课件)
Chapter6 loop-structure By: wangxia E-mail: wangxia1026@163.com contents 6.0 review 6.1 introduction 6.2 “goto” statement and goto-loop 6.3 “while” statement 6.4 “do-while” statement 6.5 “for” statement 6.6 nested loop 6.7 comparison among loops contents 6.8 “break” statement and “continue” statement 6.9 give a example exercises review 1、if-statement: if(10=x=20) wrong if(x=10x=20) right 2、tc3.0: menu—windows: message output 3、switch---case 6.1 introduction 1、application widely 2、mode: Goto + if While Do-while for 6.2 “goto” statement and goto-loop 1、how to use? Goto statement number; 2、example: 3、we donot use “goto-statement” if we can. 6.3 “while” statement 1、be used to implement “when-loop”. 2、characteristic: ---- first judge, (1) then implement 3、be used when loop-times is not fixed. 6.3 “while” statement Example: 6.4 “do-while” statement 1、how to use? 2、first implement then judgement 3、when expression=0; end; 6.4 “do-while” statement 6.3 “while” statement ex6.3 用do--while语句求∑n。先画出流程图. 6.3 compare “while” with “do-while main ( ) {int sum=0,i; scanf(“%d”,i); while (i=10) { sum=sum+i; i++; } printf(“sum=%d”,sum); } 6.5 “for” statement 1、how to use? 2、how to implement? (1) at first, get the result of “expression1”。 (2) expression2, if it is “true”, then, carry out built-in statements,turn to “(3)” ; else,end the loop,turn to “(5)” . 6.5 “for” statement (3)expression3; (4)turn to “(2)”; (5)end the loop; 6.5 “for” statement 3、simple form: for( initialize the loop-variable; loop-condition; increment of loop-variable) statement; 6.5 “for” statement 4、three expressions can be omitted. ex: for(;i=10;i++) for(;;i++) for(i=1;;i++) for(;;;) 5、for(sum=0,i=1;i=100;i++) sum=sum+i; for(i=0,j=100;i=j;i++,j--) k+=i*j; * * ex6.1:用if语句和goto语句构成循
您可能关注的文档
最近下载
- 中医基础理论:气一元论.ppt VIP
- DB61_T 2002-2025 窄轨旅游轨道交通施工技术规范.pdf VIP
- DB61_T 2004-2025 水性环氧改性微表处施工技术规范.pdf VIP
- 北京市装配式建筑项目预制率和装配率计算说明及示例.ppt VIP
- 火灾报警控制器简单操作.doc VIP
- DB61_T 2012-2025 沥青路面一体化就地热再生施工技术规范.pdf VIP
- DB61_T 2013-2025 沥青路面半刚性基层微裂均质化处治施工技术规范.pdf VIP
- 单件流培训.ppt VIP
- 隧道工程应急处置方案(3篇).docx VIP
- 海关面试题及答案.doc VIP
原创力文档

文档评论(0)