unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 =
class(TForm)
Button1: TButton;
ListBox1: TListBox;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure BubbleSort(Items: TStrings);
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 Items[i] > 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.Button1Click(Sender: TObject);
var zahl: integer;
begin
zahl:=random(100)+1;
memo1.lines.add(IntToStr(zahl));
listbox1.items:=memo1.lines;
listbox1.sorted:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;
end;
end.