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;
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 const
  n=10;
  m=10;
 Type
 Mas2=array[1..n,1..m] of extended;
 Mas1=array[1..1,1..m] of extended;

var
  Form1: TForm1;
  a: Mas2;
  b: Mas1;
  k,i,j: 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 m do
for j:=1 to n do
if max<a[j,i] then max:=a[j,i];
for j:=1 to n do begin
b[j,1]:=a[j,i]  ;
a[j,i]:=a[j,1]   ;
a[j,1]:=b[j,1]    ;
end;
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[i,j]:=random;
   StringGrid1.Cells[i,j]:=FloatToStr(a[i,j]);
  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]:='Массив' ;
for i:=1 to n do begin
  StringGrid1.Cells[0,i]:='i='+IntToStr(i);
  StringGrid1.Cells[i,0]:='j='+IntToStr(i);
  end;

end;

end.
