伪代码教程


起一篇伪代码基础教程

伪代码(Pseudo code)是一种介于计算机语言自然语言间的文字和符号,是表达算法的简单而有效的方法。伪代码不需要关注底层是如何实现的,本身就是算法框架的逻辑模型。

一、赋值语句

赋值号ABA\leftarrow B,表示将BB的内容传递给AA,相当于:A=BA=B

二、输入输出

输入

Input: input parameters A,B,CInput:\ input\ parameters\ A,B,C

输出

Output: output resultOutput:\ output \ result

三、条件语句

If A then BElse CEnd ifIf\ A \ then \ B \\ Else \ C \\ End\ if

四、循环语句

4.1 for循环

for i=1i=N doend forfor\ i=1\rightarrow i=N\ do\\ end \ for

4.2 while循环

While AYour sentencesEnd whileWhile \ A \\ Your\ sentences \\ End \ while


一个简单的栗子🔶

image-20220803174851918