Pascal - continue 语句
Pascal 中的 continue 语句的工作方式有点类似于 break 语句。 然而,继续并没有强制终止,而是强制进行循环的下一次迭代,并跳过其间的任何代码。
对于 for-do 循环,continue 语句会导致循环的条件测试和增量部分执行。 对于 while-do 和 repeat...until 循环,continue 语句使程序控制传递到条件测试。
语法
Pascal 中的 continue 语句的语法如下 −
continue;
流程图
示例
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

