主题:一个程序问题
Program exp3(input,output);
label xx;
VAR I,J,S:INTEGER;
B :ARRAY[0..5] OF INTEGER;
BEGIN
S:=1;
FOR I:=1 TO 5 DO B[I]:=I;
J:=1;
WHILE J>0 DO
BEGIN
J:=5;
WHILE (J>0) AND (B[J]=10+J-5) DO goto xx; J:=J-1;
IF J>0 THEN
BEGIN
S:=S+1; B[J]:=B[J]+1;
FOR i:=J+1 TO 5 DO B[i]:=B[J]+i-J
END;
END;
xx:writeln(j,' ',b[j]);
END.
为什么输出5 10 而不是5 5呢
label xx;
VAR I,J,S:INTEGER;
B :ARRAY[0..5] OF INTEGER;
BEGIN
S:=1;
FOR I:=1 TO 5 DO B[I]:=I;
J:=1;
WHILE J>0 DO
BEGIN
J:=5;
WHILE (J>0) AND (B[J]=10+J-5) DO goto xx; J:=J-1;
IF J>0 THEN
BEGIN
S:=S+1; B[J]:=B[J]+1;
FOR i:=J+1 TO 5 DO B[i]:=B[J]+i-J
END;
END;
xx:writeln(j,' ',b[j]);
END.
为什么输出5 10 而不是5 5呢