Const n = 5;
const m = 5;
var a:array [1..n,1..m] of integer;
i,j,k,l,max,min:integer;
begin
randomize;
for i:=1 to n do
begin
for j:=1 to m do
begin
a[i,j]:=random(30)+1;
write (a[i,j]:4);
end;
writeln;
end;
max:=1;
min:=1;
k:=1;
l:=1;
for i:=1 to n do
for j:=1 to m do
if a[i,j]>a[max,k] then
begin
max:=i;
k:=j;
end else if a[i,j] begin
min:=i;
l:=j;
end;
writeln ('Max: ',a[max,k],'. Index: [',max,',',k,']');
writeln ('Min: ',a[min,l],'. Index: [',min,',',l,']');
end.