- 2
- 0
- 约2.44千字
- 约 10页
- 2017-01-07 发布于北京
- 举报
[循环语句执行流程
循环语句执行流程 辽宁科技大学 黄建 mtysoft@163.com while语句求和 while语句与自增 for语句的一般格式 回文数 三种循环语句 三种循环语句的比较 continue 语句 学习的方法 课后题:输出数列的值 * * Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. int i = 1, s = 0; while (i = 100) { s = s + i; i = i + 1; } i = 1 s = 0 ,2 ,3 +1 +2 ,… ,99 ,100 ,101 +… +99 +100 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. int i = 0, s = 0; while (i++ = 100) s += i; i = 0 s = 0 ,1 ,2 +1 +2 ,… ,99 ,100 ,101 +… +99 +100 +101 ,102 ① i = 100 必做 真:循环 假:退出 ② i++ 必做 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. for (表达式1; 表达式2; 表达式3) { 语句 } 例如,下面的程序计算1至100的和: for (s = 0, i = 1; i = 100; i++) s += i; Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. a = 456; b = 0; w = a; do { b = b * 10 + a % 10; a = a / 10; }while (a 0); b = 0; a = 456; w = 456; a = 456/10 = 45; b = 0*10+6 = 6; b = 6*10+5 = 65; b = 65*10+4 = 654; a = 45/10 = 4; a = 4/10 = 0; if (b==w) printf(是); else printf(否); 回文数: 66,121,8998,7 不是: 456,67 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. 循环语句比较 i = 100; s = 0; do { s++; } while (i = 9); s = 0; for (i = 100; i = 9; i++) s++; i = 100; s = 0; while (i = 9) s++; Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. while 语句 for 语句 do - while 语句 当循环次数无法确定,需根据某个条件控制循环次数时,通常用 while 语句。 当已经知道循环次数的时候,用 for 语句比较方便。 当需要先执行循环体,后判断循环条件时,用 do - while 语句。 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. for (表达式1; 表达式2; 表达式3) { 语句1; continue; 语句2; } while (表达式) { 语句1; continue; 语句2; } do { 语句1; continue; 语句2; }while (表达式); Evaluation only. Created with Aspose.Slides for
您可能关注的文档
- [各种茶类的功能与作用以及茶知识大全.doc
- [房地产项目管理软件project的应用.doc
- [房地产项目结构成本的优化控制及最新管理思路与技术方法.doc
- [各种茶叶的功效不要喝错.doc
- [各种网购网.doc
- [房地产项目销售管理周报.doc
- [影响农业的区位因素及商品谷物农业.ppt
- [各种茶叶的功效.doc
- [影响力介绍.ppt
- [房地产风险投资理论.doc
- 广东省广州省实验中学教育集团2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 广东省广州大学附属中学2025-2026学年八年级上学期奥班期中物理试题(解析版).docx
- 广东省广州市第八十六中学2025-2026学年八年级上学期期中物理试题(含答案).docx
- 广东省广州市第八十九中学2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 广东省广州市第二中学2025-2026学年八年级上学期期中考试物理试题(含答案).docx
- 广东省广州市第八十六中学2025-2026学年八年级上学期期中物理试题(解析版).docx
- 广东省广州市第八十九中学2025-2026学年八年级上学期期中考试物理试题(含答案).docx
- 广东省广州市第二中学2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 2026《中国人寿上海分公司营销员培训体系优化研究》18000字.docx
- 《生物探究性实验教学》中小学教师资格模拟试题.docx
最近下载
- 西师版五年级数学下册全套电子教案(表格式)(最全).doc VIP
- 2025年AWS认证CloudFront与Route53延迟_地理路由缓存行为专题试卷及解析.pdf VIP
- 2025年互联网营销师元宇宙互动剧本杀与沉浸式剧情营销专题试卷及解析.pdf VIP
- 2025年房地产经纪人投资回报率与投资回报率自动化分析专题试卷及解析.pdf VIP
- 2025年无人机驾驶员执照国际民航组织(ICAO)标准专题试卷及解析.pdf VIP
- 井下中央变电所高压开关整定计算说明书.pdf
- 2025年房地产经纪人商品房交付条件与标准专题试卷及解析.pdf VIP
- 异位妊娠护理教学查房【40页】.pptx VIP
- PLC-S7-200-SMART-与LabVIEW-OPC-以太网通信.pdf VIP
- 全球百强创新集群排行榜.pdf VIP
原创力文档

文档评论(0)