网站大量收购闲置独家精品文档,联系QQ:2885784924

第五章概述.pptx

  1. 1、本文档共56页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第五章概述分析

第5章 选择控制结构;本章学习内容;生活中的问题求解: Problem: 烤蛋糕(Baking a Cake) How to solve: Start 将烤箱预热 准备一个盘子 在盘子上抹上一些黄油 将面粉、鸡蛋、糖和香精混合在一起搅拌均匀 将搅拌好的面粉团放在盘子上 将盘子放到烤箱内 End ;Problem: 准备早餐( Prepare a Breakfast) ;1. Start 2. 准备早餐 2.1 准备一个金枪鱼三明治 2.2 准备一些薯条 2.3 冲一杯咖啡 3. End; “分而治之”策略 (Divide and Conquer Strategy );1. Start 2.准备早餐 2.1 准备一个金枪鱼三明治 2.1.1 拿来两片面包 2.1.2 准备一些金枪鱼酱 2.2 准备一些薯片 2.2.1 将土豆切成片 2.2.2 油炸这些土豆片 2.3 冲一杯咖啡 3. End;1. Start 2.准备早餐 2.1 准备一个金枪鱼三明治 2.1.1 拿来两片面包 2.1.2 准备一些金枪鱼酱 2.2 准备一些薯片 2.2.1 将土豆切成片 2.2.2 油炸这些土豆片 2.3 冲一杯咖啡 2.3.1 烧些开水放入杯中 2.3.2 在水杯中加入一些咖啡和糖 3. End;5.2 算法的概念及其描述方法;5.2 算法的概念及其描述方法;5.2 算法的概念及其描述方法;流程图(Flowchart);计算机中的问题求解过程;顺序结构( Sequence Structure);【例5.1】计算两整数的最大值 ;;关系运算符 (比较运算符);5.4 用于单分支控制的条件语句 (Single Selection);The structure is similar to single selection (flowchart);if Statement;【例5.1】计算两整数的最大值;Pseudocode Structure Step a if condition is true start Step m Step n end_if else start Step x Step y end_else Step z;if - else Statement;;scanf(%d,%d, a, b);;#include stdio.h main() { int a, b, max; printf(Input a, b:); scanf(%d,%d, a, b); if (a b) max = a; else max = b; printf(max = %d, max); };#include stdio.h main() { int a, b, max; printf(Input a, b:); scanf(%d,%d, a, b); if (a b) max = a; else max = b; printf(max = %d, max); };;Cascaded if Step a if (expression1) { Step m } else if (expression2) { Step n } else { Step x } Step z;The structure is similar to multiple selection (flowchart);Important Rule !;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);;Example: switch (month) { case 1: printf(January\n); break; case 2: printf(February\n); break; case 3: printf(March\n); brea

文档评论(0)

10577 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档