← All examples

Maximum in a matrix

Pascal Loops

nested loops

Flowchart (ISO 5807)

YesNoStartInput nm = a[1][1]i = 1, n, 1j = 1, n, 1a[i][j] > mm = a[i][j]Output mEndFigure 1 — MaxElem

Source code

program MaxElem;
var a: array[1..10, 1..10] of integer;
    i, j, n, m: integer;
begin
  readln(n);
  m := a[1][1];
  for i := 1 to n do
    for j := 1 to n do
      if a[i][j] > m then
        m := a[i][j];
  writeln(m);
end.