type TheMas = array [1..10] of array [1..10] of Integer; TForm1 = class(TForm) StringGrid1: TStringGrid; Edit1: TEdit; UpDown1: TUpDown; Label1: TLabel; Edit2: TEdit; UpDown2: TUpDown; Label2: TLabel; Button1: TButton; procedure GridChange(Sender: TObject); procedure Button1Click(Sender: TObject); procedure zap(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.GridChange(Sender: TObject); begin StringGrid1.ColCount:=UpDown1.Position; StringGrid1.RowCount:=UpDown2.Position; end;
procedure TForm1.Button1Click(Sender: TObject); var M:TheMas; i, j, k, p:Integer; begin for i:=1 to UpDown1.Position do for j:=1 to UpDown2.Position do M[i, j]:=StrToInt(StringGrid1.Cells[i-1, j-1]); k:=1; p:=M[1, 1]; for i:=1 to UpDown1.Position do for j:=2 to UpDown2.Position do if p>M[i, j] then begin k:=j; p:=M[i, j]; end; for i:=1 to UpDown1.Position do
begin
p:=M[i, 1]; M[i, k+1]:=M[i, 1];
M[i, j+1]:=p;
end;
for i:=1 to UpDown1.Position do for j:=1 to UpDown2.Position do StringGrid1.Cells[i-1, j-1]:=IntToStr(M[i, j]); end;
procedure TForm1.zap(Sender: TObject); var x,y:integer; begin randomize; for y:=0 to form1.StringGrid1.rowcount do for x:=0 to form1.StringGrid1.ColCount do form1.StringGrid1.Cells[x,y]:=inttostr(random(100)); end;