Const
n = 8;
var
i, j, umax, lmax: integer;
a: array[1..n, 1..n] of integer;
begin
Randomize;
writeln('Исходный массив');
for i := 1 to n do
begin
for j := 1 to n do
begin
a[i, j] := Random(40) - 20;
write(a[i, j]:4)
end;
writeln;
end;
umax := -100;
for i := 1 to n do
for j := i to n do
if umax < a[i, j] then umax := a[i, j];
lmax := -100;
for i := 1 to n do
for j := 1 to i do
if lmax < a[i, j] then lmax := a[i, j];
writeln('Разность максимумов равна ', umax - lmax)
end.
Тестовое решение:
Исходный массив
-5 18 -13 1 -16 5 0 -13
4 -18 -17 -14 2 10 -2 -15
-15 -8 -6 -16 -10 -12 -18 -17
-18 6 11 -5 4 -6 -1 1
10 14 3 -7 2 11 10 -1
6 -2 -20 1 4 9 13 -4
-9 -7 4 -6 -12 3 1 -14
15 -16 -1 -3 13 -15 3 -10
Разность максимумов равна 3