Show a nested loop which searches a two-dimensional array filled with random numbers uniformly distributed over 



[
1
,
…
,
20
]


{\displaystyle [1,\ldots ,20]}

.

The loops iterate rows and columns of the array printing the elements until the value 



20


{\displaystyle 20}

 is met.

Specifically, this task also shows how to break out of nested loops.



Related tasks

   Loop over multiple arrays simultaneously
   Loops/Break
   Loops/Continue
   Loops/Do-while
   Loops/Downward for
   Loops/For
   Loops/For with a specified step
   Loops/Foreach
   Loops/Increment loop index within loop body
   Loops/Infinite
   Loops/N plus one half
   Loops/Nested
   Loops/While
   Loops/with multiple ranges
   Loops/Wrong ranges


'BEGIN' 'COMMENT' Loops/Nested - ALGOL60 - 19/06/2018;
  'INTEGER' SEED;
  'INTEGER' 'PROCEDURE' RANDOM(N);
  'VALUE' N; 'INTEGER' N;
  'BEGIN'
    SEED:=(SEED*19157+12347) '/' 21647;
    RANDOM:=SEED-(SEED '/' N)*N+1
  'END' RANDOM;
  'INTEGER' 'ARRAY' A(/1:10,1:10/);
  'INTEGER' I,J;
  SEED:=31569;
  'FOR' I:=1 'STEP' 1 'UNTIL' 10 'DO'
    'FOR' J:=1 'STEP' 1 'UNTIL' 10 'DO'
      A(/I,J/):=RANDOM(20);
  SYSACT(1,6,120);SYSACT(1,8,60);SYSACT(1,12,1);'COMMENT' open print;
  'FOR' I:=1 'STEP' 1 'UNTIL' 10 'DO'
    'FOR' J:=1 'STEP' 1 'UNTIL' 10 'DO' 'BEGIN'
      OUTINTEGER(1,A(/I,J/));
      'IF' A(/I,J/)=20 'THEN' 'GOTO' LAB;
	'END';
LAB:
'END'