维基副本镜像

这是 pascal.chat 维基的镜像。编辑、历史记录和登录都在那里。

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

English · Français · Български · 中文(中国) · 日本語

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

先判断后循环:

pascal
while ??????????????? do
  ??????;

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

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

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

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

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

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

上一页 目录 下一页

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 3/WHILE..DO/zh CN", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

版本1,最后由WikiArchive于修改。