Goto 语句

语法

goto label;
   ...
   ...
label: statement;

流程图

cpp goto statement

官方样例

program exGoto;
label 1; 
var
   a : integer;
begin
   a :=10;
   (* repeat until loop execution *)
   1: repeat
      if( a =15 )then
      begin
         (* skip the iteration *)
         a := a + 1;
         goto 1;
      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
Copyright © 280i.com 2020 all right reserved,powered by Gitbook本书建立时间: 2020-04-12 00:03:37

results matching ""

    No results matching ""