52算法的概念及其描述方法 算法的描述方法 自然语言描述 传统流程图( Flowchart) 在1966年, Bohra与 Jacopini提出 NS结构化流程图 1973年,美国学者 LAssi和 B Shneiderman提出 伪码( Pseudocode)表示 2021/2/12 l1/56
2021/2/12 11/56 5.2算法的概念及其描述方法 算法的描述方法 – 自然语言描述 – 传统流程图(Flowchart) 在1966年,Bohra与 Jacopini 提出 – N-S结构化流程图 1973年,美国学者I.Nassi 和 B.Shneiderman 提出 – 伪码(Pseudocode)表示
凉褪( Flowchart) a Flowchart represents algorithm graphically. Symbol Semantic Start/End Process Input/Output es ○ Connector Flow of activities 2021/2/12 12/56
2021/2/12 12/56 流程图(Flowchart) Flowchart represents algorithm graphically. Start/End Symbol Semantic Process Input/Output Test Connector Flow of activities
功算舰中的问题求解过程 Example:买苹果,计算价钱 Calculate and display the price of a number of apples if the quantity in kg and price per kg are given. Input Process Output quantity price= quantity* pricePerkg price pricePerkg First identify the input and output of the problem. 2021/2/12 13/56
2021/2/12 13/56 计算机中的问题求解过程 Example :买苹果,计算价钱 Calculate and display the price of a number of apples if the quantity in kg and price per kg are given. • quantity • pricePerkg price = quantity * pricePerkg price Input Process Output First identify the input and output of the problem
饭序结构( Sequence Structure) 口给变量赋值 赋值表达式语句 赋值表达式; price=quantity " pricePerkg; 输入输出数据 B 标准库函数调用语句 scanf(%od",&pricePerkg printf(od", price); 2021/2/12 14/56
2021/2/12 14/56 顺序结构( Sequence Structure) 给变量赋值 – 赋值表达式语句 赋值表达式 ; price = quantity*pricePerkg; 输入输出数据 –标准库函数调用语句 scanf("%d", &pricePerkg); printf("%d", price); A B C
1算顺警数的最大值 Input Process Output e nun ??? max num2 202//1∠ 15/56
2021/2/12 15/56 【例5.1】计算两整数的最大值 • num1 • num2 max ???? Input Process Output