unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, StdCtrls;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button2: TButton;
    Button3: TButton;
    StringGrid2: TStringGrid;
    Label3: TLabel;
    Edit3: TEdit;
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 const
 Nmax=10;
 Mmax=10;

 Type
 Mas2=array[1..Mmax,1..Nmax] of extended;
 Mas1=array[1..Mmax,1..1] of extended;

var
  Form1: TForm1;
  a: Mas2;
  b: Mas1;
  k,i,j,n,m,f: integer;
  max: extended;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
{$R+}
k:=1;
while k<n do begin
max:=a[1,k];
for i:=k to n do
 for j:=1 to m do
 if max<a[j,i] then  begin
  max:=a[j,i];
  f:=i;
  Edit3.Text:=FloatToStr(max);
 end;
for j:=1 to m do begin
 b[j,1]:=a[j,f]  ;
 a[j,f]:=a[j,1]   ;
 a[j,1]:=b[j,1]    ;
end;
k:=k+1;
end;
for i:=1 to n do
 for j:=1 to m do   begin
  StringGrid2.RowCount:=n+1 ;
  StringGrid2.ColCount:=m+1 ;
  StringGrid2.Cells[i,j]:=FloatToStr(a[j,i]);
 end;
end;



procedure TForm1.Button3Click(Sender: TObject);
begin
n:=StrToInt(Edit1.Text);
m:=StrToInt(Edit2.Text);
StringGrid1.RowCount:=n+1 ;
StringGrid1.ColCount:=m+1 ;
Randomize;
for i:=1 to n do
 for j:=1 to m do begin
   a[j,i]:=random(21);
   StringGrid1.Cells[i,j]:=FloatToStr(a[j,i]);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
n:=3;
m:=3;
Edit1.Text:=FloatToStr(n);
Edit2.Text:=FloatToStr(m) ;
StringGrid1.RowCount:=n+1 ;
StringGrid1.ColCount:=m+1 ;
StringGrid1.Cells[0,0]:='Массив 1' ;
StringGrid2.RowCount:=n+1 ;
StringGrid2.ColCount:=m+1 ;
StringGrid2.Cells[0,0]:='Массив 2' ;
for i:=1 to n do begin
  StringGrid1.Cells[0,i]:='i='+IntToStr(i);
  StringGrid1.Cells[i,0]:='j='+IntToStr(i);
  end;
for i:=1 to n do begin
  StringGrid2.Cells[0,i]:='i='+IntToStr(i);
  StringGrid2.Cells[i,0]:='j='+IntToStr(i);
  end;

end;

end.
