const n=5; m=4; var A: array[1..n,1..m] of integer; max,min,n1,n2: integer; begin writeln('Исходный массив:'); for var i:=1 to n do begin for var j:=1 to m do begin A[i,j]:=random(100); write(A[i,j]:3); if (i=1) and (j=1) then min:=A[i,j]; if A[i,j]<min then begin min:=A[i,j]; n1:=i; end; if A[i,j]>max then begin max:=A[i,j]; n2:=i; end; end; writeln; end; writeln('min=',min,'; max=',max,'; n1=',n1,'; n2=',n2); for var i:=1 to m do swap(A[n1,i],A[n2,i]); writeln('Преобразованный массив:'); for var i:=1 to n do begin for var j:=1 to m do write(A[i,j]:3); writeln; end; end.
Answers & Comments
const
n=5;
m=4;
var
A: array[1..n,1..m] of integer;
max,min,n1,n2: integer;
begin
writeln('Исходный массив:');
for var i:=1 to n do
begin
for var j:=1 to m do
begin
A[i,j]:=random(100);
write(A[i,j]:3);
if (i=1) and (j=1) then min:=A[i,j];
if A[i,j]<min then
begin
min:=A[i,j];
n1:=i;
end;
if A[i,j]>max then
begin
max:=A[i,j];
n2:=i;
end;
end;
writeln;
end;
writeln('min=',min,'; max=',max,'; n1=',n1,'; n2=',n2);
for var i:=1 to m do swap(A[n1,i],A[n2,i]);
writeln('Преобразованный массив:');
for var i:=1 to n do
begin
for var j:=1 to m do
write(A[i,j]:3);
writeln;
end;
end.