目录

continue statement

Pascal中的continue语句有点像break语句。 但是,不是强制终止,而是continue强制执行循环的下一次迭代,跳过其间的任何代码。

对于for-do循环, continue语句会导致条件测试并增加循环的部分来执行。 对于while-dorepeat...until循环, continue语句使程序控制转到条件测试。

语法 (Syntax)

Pascal中continue语句的语法如下 -

continue;

流程图 (Flow Diagram)

Pascal继续声明

例子 (Example)

program exContinue; 
var
   a: integer;
begin
   a := 10;
   (* repeat until loop execution *)
   repeat
      if( a = 15) then
      begin
         (* skip the iteration *)
         a := a + 1;
         continue;
      end;
      writeln('value of a: ', a);
      a := a+1;
   until ( a = 20 );
end.

编译并执行上述代码时,会产生以下结果 -

value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19
↑回到顶部↑
WIKI教程 @2018