Basic Pascal Tutorial/Chapter 3/REPEAT..UNTIL/zh CN

This is an old revision of Basic Pascal Tutorial/Chapter 3/REPEAT..UNTIL/zh CN, edited by Trev at . The current revision is 95305.

Fixed syntax highlighting; removed categories included in template

Template:REPEAT..UNTIL

REPEAT..UNTIL循环 (原作者: Tao Yue, 状态: 未更改)

先循环后判断:

repeat
  语�1;
  语�
until 逻辑表达�;

在repeat循环中,复合语句是内置的,因此,你不需要使用begin-end。另外,直至表达式值为真退出循环。

REPEAT循环被称之为先循环后判断,任何情况下,循环至少执行一次。

var
    sum,count : integer;

begin
    sum := 0;
    count := 0;

    repeat
        count := count + 1;
        sum := sum + count
    until (count >= 100);

    writeln('sum=', sum);
end.
上一页 目录 下一页