unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    StringGrid1: TStringGrid;
    StringGrid2: TStringGrid;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

const
  Nmax=10;
Type
Mas1 = array[1..Nmax,1..Nmax] of extended;

var
  Form1: TForm1;
  A : Mas1;
  N, M : integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var i,j:integer;
begin
 N:=3;
 M:=3;

 Edit1.Text:=FloatToStr(N);
 Edit2.Text:=FloatToStr(M);

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

 StringGrid1.Cells[0,0]:='матрица н';
 StringGrid2.Cells[0,0]:='матрица н-1';

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

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


end;

procedure TForm1.Button1Click(Sender: TObject);
VAR i,j : integer;
begin
 N:=StrToInt(Edit1.Text);
 M:=StrToInt(Edit2.Text);

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

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

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

end;

procedure TForm1.Button2Click(Sender: TObject);
var max:extended;
    imax,jmax,i,j,skipi,skipj:integer;
begin
 {$R+}
   //try
     for i:=1 to N do
       for j:=1 to M do
         A[i,j]:=StrToFloat(StringGrid1.Cells[i,j]);
   //except
     //on ERangeError do begin ShowMessage('размер'); Exit; end;
     //on EConvertError do begin ShowMessage('кривое число'); Exit; end;
   //else begin ShowMessage('хз'); Exit; end;

   //try
       max:=abs(A[1,1]);
       imax:=1;
       jmax:=1;
       for i:=1 to N do
         begin
         for j:=1 to M do
           begin
           if abs(A[i,j])>max then
             begin
               max:=A[i,j];
               imax:=i;
               jmax:=j;
             end;
           end;
         end;
StringGrid2.Cells[0,0]:=floattostr(max);

       skipi := 0;
       for i:=1 to N do
         if i=imax then
           skipi := 1
         else
           begin
           skipj:=0;
           for j:=1 to M do
             if j=jmax then
               skipj := 1
             else
               StringGrid2.Cells[i-skipi,j-skipj]:=floattostr(A[i,j]);
            end;
   //except
     //   on EInvalidOp do begin MessageDlg('не могу такое дело',mtError,[mbCancel],0);Exit; end;
      //  on EOverFlow do begin MessageDlg('перегруз',mtError,[mbCancel],0); Exit; end;
   //else begin MessageDlg('шило какое-то',mtError,[mbCancel],0); Exit; end;
end;

//end;
//end;
end.


