unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
ListBox1: TListBox;
ListBox2: TListBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure BubbleSort(Items: TStrings);
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
procedure TForm1.BubbleSort(Items: TStrings); var done: boolean; i, n: integer;
Dummy: string;
begin
n := Items.Count;
repeat
done := true;
for i := 0 to n - 2 do
if StrToInt(Items[i]) > StrToInt(Items[i - 1]) then
begin
Dummy := Items[i];
Items[i] := Items[i - 1];
Items[i - 1] := Dummy;
done := false;
end;
until done;
end;
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;
end;
procedure TForm1.Button1Click(Sender: TObject);
var zahl: integer;
begin
zahl:=random(100)-1;
ListBox1.Items.add(IntToStr(zahl));
listbox2.items:=ListBox1.Items;
listbox2.sorted:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox1.Caption := '';
ListBox2.Caption := '';
end;
end.