Difference between revisions of "Basic Pascal Tutorial/Chapter 3/WHILE..DO/zh CN"
From Lazarus wiki
Jump to navigationJump to searchm |
m (Fixed syntax highlighting; deleted category included in page template) |
||
(One intermediate revision by one other user not shown) | |||
Line 5: | Line 5: | ||
先判断后循环: | 先判断后循环: | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=pascal> |
while 逻辑表达式 do | while 逻辑表达式 do | ||
语句; | 语句; | ||
Line 14: | Line 14: | ||
在循环体中你必须设法改变表达式的值(即,造成为假的条件),否则,它将是一个死循环: | 在循环体中你必须设法改变表达式的值(即,造成为假的条件),否则,它将是一个死循环: | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=pascal> |
a := 5; | a := 5; | ||
while a < 6 do | while a < 6 do | ||
Line 23: | Line 23: | ||
通过改变变量,以避免循环: | 通过改变变量,以避免循环: | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=pascal> |
a := 5; | a := 5; | ||
while a < 6 do | while a < 6 do | ||
Line 39: | Line 39: | ||
|[[REPEAT..UNTIL/zh_CN|下一页]] | |[[REPEAT..UNTIL/zh_CN|下一页]] | ||
|} | |} | ||
− | |||
− | |||
− |
Revision as of 10:51, 4 March 2020
│
български (bg) │
English (en) │
français (fr) │
日本語 (ja) │
中文(中国大陆) (zh_CN) │
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 称之为先判断后循环,即,在进入循环前,先判断条件是否为真,如果为假,将不会进入循环。
上一页 | 目录 | 下一页 |