http://rghost.ru/52641190
Вот код
Код: Выделить всё
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
b:string;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0,0]:='Номер элемента';
StringGrid1.Cells[1,0]:='1';
StringGrid1.Cells[2,0]:='2';
StringGrid1.Cells[3,0]:='3';
StringGrid1.Cells[4,0]:='4';
StringGrid1.Cells[5,0]:='5';
StringGrid1.Cells[0,1]:='Исходный массив';
StringGrid1.Cells[0,2]:='Первый просмотр';
StringGrid1.Cells[0,3]:='Второй просмотр';
StringGrid1.Cells[0,4]:='Третий просмотр';
StringGrid1.Cells[0,5]:='Четвертый просмотр';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if strtoint(stringgrid1.Cells[1,2])> strtoint(stringgrid1.Cells[2,2])
then
begin b:=stringgrid1.Cells[2,2];
stringgrid1.Cells[2,2]:=stringgrid1.Cells[1,2];
stringgrid1.Cells[1,2]:=b;
end;
if strtoint(stringgrid1.Cells[2,2])> strtoint(stringgrid1.Cells[3,2])
then
begin b:=stringgrid1.Cells[3,2];
stringgrid1.Cells[3,2]:=stringgrid1.Cells[2,2];
stringgrid1.Cells[2,2]:=b;
end;
if strtoint(stringgrid1.Cells[3,2])> strtoint(stringgrid1.Cells[4,2])
then
begin b:=stringgrid1.Cells[4,2];
stringgrid1.Cells[4,2]:=stringgrid1.Cells[3,2];
stringgrid1.Cells[3,2]:=b;
end;
end;

Так же нужно доделать: 2,3,4 кнопку, чтобы довести результат до конца! Кто может помочь?