Basic Pascal Tutorial/Chapter 3/WHILE..DO/zh CN

This is an old revision of Basic Pascal Tutorial/Chapter 3/WHILE..DO/zh CN, edited by Trev at . The current revision is 95313.

Fixed syntax highlighting; deleted category included in page template

Template:WHILE..DO

3Db - WHILE..DO循环 (原作者: Tao Yue, 状态: 未更改)

先判断后循环:

while 逻辑表达� do
  语�;

判断逻辑表达式为真,则继续执行循环;直至表达式为假将退出循环。

在循环体中你必须设法改变表达式的值(即,造成为假的条件),否则,它将是一个死循环:

a := 5;
while a < 6 do
  writeln (a);

通过改变变量,以避免循环:

a := 5;
while a < 6 do
begin
  writeln (a);
  a := a + 1
end;

WHILE...DO 称之为先判断后循环,即,在进入循环前,先判断条件是否为真,如果为假,将不会进入循环。

上一页 目录 下一页