unit UnitL4v9;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    StringGrid1: TStringGrid;
    StringGrid2: TStringGrid;
    Button2: TButton;
    BitBtn1: TBitBtn;
    Label3: TLabel;
    Label4: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    //procedure Button1Click(Sender: TObject);
    //procedure massiv(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
const Max=10;
Type
Mas=array[1..Max,1..Max] of extended;

var
  Form1: TForm1;
Var
  MaxS,N,M,i,j,SCH:integer;
  MaxEl:extended;
  A,B:Mas;
implementation

{$R *.DFM}
procedure massiv;
begin
N:=StrToInt(Form1.Edit1.Text);
M:=StrToInt(Form1.Edit2.Text);

 Form1.StringGrid1.RowCount:=M+1;
 Form1.StringGrid1.ColCount:=N+1;
 Form1.StringGrid2.RowCount:=M+1;
 Form1.StringGrid2.ColCount:=N+1;

  for i:=1 to N do begin
    Form1.StringGrid1.Cells[i,0]:='i='+IntToStr(i);
    Form1.StringGrid2.Cells[i,0]:='i='+IntToStr(i);

                   end;
  for j:=1 to M do begin
    Form1.StringGrid1.Cells[0,j]:='j='+IntToStr(j);
    Form1.StringGrid2.Cells[0,j]:='j='+IntToStr(j);
                   end;
   for i:=1 to N do
     for j:=1 to M do
                        begin
   Form1.StringGrid1.Cells[i,j]:=IntToStr(Random(10));
   Form1.StringGrid2.Cells[i,j]:='';
   B[i,j]:=0;
                        end;
end;
procedure TForm1.FormCreate(Sender: TObject);

 begin
Edit1.Text:='3';
Edit2.Text:='3';
StringGrid1.Cells[0,0]:='Массив А';
StringGrid2.Cells[0,0]:='Массив B';
 massiv;
 end;

procedure TForm1.Button1Click(Sender: TObject);
begin
massiv;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  {Заполнение массива А из StringGrid1}
    for i:=1 to N do
     for j:=1 to M do
    A[i,j]:=StrToFloat(Form1.StringGrid1.Cells[i,j]);

 {Вычисление массива}
 begin
     MaxS:=1;
     MaxEl:=A[1,1];
     for SCH:=1 to M do begin
                                 MaxS:=1;
                                 MaxEl:=A[1,1];
        for i:=1 to N do
           for j:=1 to M do
           if A[i,j]>MaxEl then  begin
                                   MaxEl:=A[i,j];
                                   MaxS:=j;
                                 end;

         j:=MaxS;
            for i:=1 to N do begin
               B[i,SCH]:=A[i,j];
               A[i,j]:=0;
                             end;
                          end;

 end;

    {Вывод массива В в StringGrid2}
      for i:=1 to N do
     for j:=1 to M do
    StringGrid2.Cells[i,j]:=FloatToStr(B[i,j]);

end;

end.
