```
var a:array[1..100,1..100]of integer;
N, M, i, j, mini, minj, maxi, maxj :integer;
begin
write('N, M -> ');
readln(N, M); {считываем размер матрицы}
write('Input matrix -> ');
for i:=1 to N do for j:=1 to M do
begin
write('A[',i,',',j,'] -> ');
readln(a[i, j]);
end; {считываем саму матрицу}
readln;
mini:=1;
minj:=1;
maxi:=2;
maxj:=2;
for i:=1 to N do for j:=1 to M do if a[i,j] > a[maxi, maxj] then
begin
maxi := i;
maxj := j;
end else if a[i, j] < a[mini, minj] then
begin
mini := i;
minj := j;
end;
writeln('MAX = A[',maxi,',',maxj,'] = ', a[maxi, maxj]);
writeln('MIN = A[',mini,',',minj,'] = ', a[mini, minj]);
readln;
end. ```