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;
    Memo1: TMemo;
    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..Nmax,1..Mmax] of integer;
var
  Form1: TForm1;
  a: Mas2;
  S,i,j,n,m, k,f,p: integer;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
{$R+}
  for j:=1 to m do
for i:=1 to n do
A[i,j]:=Strtoint(stringgrid1.Cells[i,j]);
  k:=0;
 For j:=1 to m do begin
 For i:=1 to n do begin
 p:=a[j,i];
 for f:=1 to n do
 S:=S+a[j,f];
 S:=S-p;
 If p>S then k:=k+1;
 S:=0;
 end;end;
 Memo1.Lines.add('K='+inttostr(k));

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(100);
   StringGrid1.Cells[i,j]:=FloatToStr(a[i,j]);
  end;
end;

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


end;

end.
