伪代码
伪代码的编写更接近于编程语言。它可以被认为是增强的编程语言,充满了注释和描述。伪代码避免了变量声明,但它们使用一些实际的编程语言结构编写的,如 C,Fortran 和 Pascal 等。
伪代码包含比结构化英语更多的编程细节。它提供了一种执行任务的方法,就好像计算机正在执行代码一样。
示例
打印最多 n 个数字的斐波那契数列的程序。
void function Fibonacci
Get value of n;
Set value of a to 1;
Set value of b to 1;
Initialize I to 0
for (i=0; i< n; i++)
{
if a greater than b
{
Increase b by a;
Print b;
}
else if b greater than a
{
increase a by b;
print a;
}
}
页:
[1]