unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    StringGrid1: TStringGrid;
    Button2: TButton;
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
const
   nmax=10;
Type
  mas=array[1..nmax,1..nmax] of integer;
var
  Form1: TForm1;
  a:mas;
  n,m,i,j,k,w,e,r,q:integer;

implementation


{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin

n:=3;
m:=3;
 Edit1.Text:=FloatToStr(n);
 Edit2.Text:=FloatToStr(m);
 StringGrid1.RowCount:=m+1;
 StringGrid1.ColCount:=n+1;
 StringGrid1.Cells[0,0]:='Мaссив А';
 For i:=1 to n do
    StringGrid1.Cells[i,0]:='I='+IntToStr(i);
 For j:=1 to m do
    StringGrid1.Cells[0,j]:='J='+IntToStr(j);
randomize;
   for i:=1 to n do
     for j:=1 to m do
       begin
         q:=random(10);
         stringgrid1.Cells[i,j]:=inttostr(q);
         a[j,i]:=q;
       end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
n:=StrToInt(Edit1.text);
m:=StrToInt(Edit2.text);
StringGrid1.RowCount:=m+1;
StringGrid1.ColCount:=n+1;
For i:=1 to n do
    StringGrid1.Cells[i,0]:='I='+IntToStr(i);
 For j:=1 to m do
    StringGrid1.Cells[0,j]:='J='+IntToStr(j);
 randomize;
   for i:=1 to n do
     for j:=1 to m do
       begin
         q:=random(10);
         stringgrid1.Cells[i,j]:=inttostr(q);
         a[j,i]:=q;
       end;

end;
procedure TForm1.Button2Click(Sender: TObject);
begin

  k:=0;
  for i:=1 to n do begin
  for j:=2 to m-1 do begin
    w:=A[i,j-1];
    e:=A[i,j+1];
    r:=A[i,j];
    if w<r then
    if r<e then k:=k+1;

for i:=1 to n do
  for j:=1 to m do
     stringGrid1.Cells[i,j]:=inttostr(a[j,i]);
Memo1.Lines.Add('Количество элементов ' + FloattoStr(k));
end;
end;
end;
end.
