unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids; type TForm1 = class(TForm) StringGrid1: TStringGrid; StringGrid2: TStringGrid; StringGrid3: TStringGrid; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; const a=4; b=4; var Form1: TForm1; mas array [1..a, 1..b] of integer; var i,j,k:byte; x:integer; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin for i:=1 to a do for j:=1 to b do mas [i,j]:=strtoint(stringgrid1.Cells); if chekbox1.checked then for j:=1 to b do for k:=a downto 2 do for i:=1 to k-1 do if mas [i,j]>mas[i+1,j] then begin x:=mas[i,j]; mas[i,j]:=mas[i+1,j]; mas[i+1,j]:=x end; for i:=1 to a do for j:=1 to b do stringgrid2.Cells[j,i]:=inttostr(mas(i,j)); end; end.