Uses crt;
Type MyType = real;
Var
n,m,i,j,xi,xj: byte;
a: array[1..100,1..100] of MyType;
Procedure Stroka(i,i1: byte);
var
j: byte;
buf: MyType;
begin
For j:=1 to m do
begin
buf:=a[i,j];
a[i,j]:=a[i1,j];
a[i1,j]:=buf
end
end;
Procedure Stolb(j,j1: byte);
var
i: byte;
buf: MyType;
begin
For i:=1 to n do
begin
buf:=a[i,j];
a[i,j]:=a[i,j1];
a[i,j1]:=buf
end
end;
Begin
Clrscr;
Write('n=');
Readln(n);
Write('m=');
Readln(m);
Randomize;
For i:=1 to n do
begin
For j:=1 to m do
begin
a[i,j]:=random*20-5;
Write(a[i,j]:5:1);
end;
Writeln;
end;
Writeln;
xi:=1; xj:=1;
For i:=1 to n do
For j:=1 to m do
If a[i,j] > a[xi,xj] then
begin
xi:=i;
xj:=j
end;
While xi < n do
begin
Stroka(xi,xi+1);
Inc(xi)
end;
While xj > 1 do
begin
Stolb(xj,xj-1);
Dec(xj)
end;
For i:=1 to n do
begin
For j:=1 to m do write(a[i,j]:5:1);
Writeln
end;
End
Type MyType = real;
Var
n,m,i,j,xi,xj: byte;
a: array[1..100,1..100] of MyType;
Procedure Stroka(i,i1: byte);
var
j: byte;
buf: MyType;
begin
For j:=1 to m do
begin
buf:=a[i,j];
a[i,j]:=a[i1,j];
a[i1,j]:=buf
end
end;
Procedure Stolb(j,j1: byte);
var
i: byte;
buf: MyType;
begin
For i:=1 to n do
begin
buf:=a[i,j];
a[i,j]:=a[i,j1];
a[i,j1]:=buf
end
end;
Begin
Clrscr;
Write('n=');
Readln(n);
Write('m=');
Readln(m);
Randomize;
For i:=1 to n do
begin
For j:=1 to m do
begin
a[i,j]:=random*20-5;
Write(a[i,j]:5:1);
end;
Writeln;
end;
Writeln;
xi:=1; xj:=1;
For i:=1 to n do
For j:=1 to m do
If a[i,j] > a[xi,xj] then
begin
xi:=i;
xj:=j
end;
While xi < n do
begin
Stroka(xi,xi+1);
Inc(xi)
end;
While xj > 1 do
begin
Stolb(xj,xj-1);
Dec(xj)
end;
For i:=1 to n do
begin
For j:=1 to m do write(a[i,j]:5:1);
Writeln
end;
End