program lab5_dvum_mass_var8;
const n=5; m=5;
type ar=array[1..n,1..m] of integer;
type br=array[1..n] of integer;
var i,z,t,j,nm,imax,jmax,max:integer; a:ar;
procedure vvod(var a:ar);
var i,j:integer;
begin
for i:=1 to n do
for j:=1 to m do
a[i,j]:=random(51);
end;
procedure vivod(a:ar);
var i,j:integer;
begin
for i:=1 to n do
begin
for j:=1 to m do
write(a[i,j]:5);
writeln;
end;
end;
begin
vvod(a);
vivod(a);
begin
max:=0;
for i:=1 to n do
for j:=1 to m do
if i=j then
begin
if a[i,j]>max then
begin
max:=a[i,j]; imax:=i; jmax:=j;
end;
end;
end;
writeln('element,' ',max:2,' ','ryadok',imax:2,' ',stolbec',jmax:2);
Repeat
write('vvedite nomer ryadka: ');readln(nm);
Until nm in [1..n];
For j:=1 to m do
Begin
t:=A[nm,j];
A[nm,j]:=A[imax,j];
A[imax,j]:=t;
End;
writeln('preobrazovannaya matrica');
vivod(a);
writeln;
end.
const n=5; m=5;
type ar=array[1..n,1..m] of integer;
type br=array[1..n] of integer;
var i,z,t,j,nm,imax,jmax,max:integer; a:ar;
procedure vvod(var a:ar);
var i,j:integer;
begin
for i:=1 to n do
for j:=1 to m do
a[i,j]:=random(51);
end;
procedure vivod(a:ar);
var i,j:integer;
begin
for i:=1 to n do
begin
for j:=1 to m do
write(a[i,j]:5);
writeln;
end;
end;
begin
vvod(a);
vivod(a);
begin
max:=0;
for i:=1 to n do
for j:=1 to m do
if i=j then
begin
if a[i,j]>max then
begin
max:=a[i,j]; imax:=i; jmax:=j;
end;
end;
end;
writeln('element,' ',max:2,' ','ryadok',imax:2,' ',stolbec',jmax:2);
Repeat
write('vvedite nomer ryadka: ');readln(nm);
Until nm in [1..n];
For j:=1 to m do
Begin
t:=A[nm,j];
A[nm,j]:=A[imax,j];
A[imax,j]:=t;
End;
writeln('preobrazovannaya matrica');
vivod(a);
writeln;
end.