unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons; type TForm1 = class(TForm) BitBtn1: TBitBtn; Button1: TButton; ListBox1: TListBox; Button2: TButton; ListBox2: TListBox; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; const Werteb = 1000; const Anzahl = 100; Type Bereich = Array[1..Anzahl] of Integer; var Form1: TForm1; Z: bereich; implementation {$R *.DFM} procedure zufall(var Z: Bereich; Anz,Wertebereich: integer); var i,j: integer; gleich: boolean; begin randomize; Z[1]:= random(Wertebereich)+1; for i := 2 to anz do repeat Z[i] := random(Wertebereich)+1; gleich := false; for j := 1 to (i-1) do if Z[i]=Z[j] then begin gleich := true; break; end; until not gleich; end; procedure TForm1.Button1Click(Sender: TObject); var i:integer; begin Listbox1.clear; zufall(Z,Anzahl,Werteb); for i := 1 to Anzahl do Listbox1.Items.Add(inttostr(Z[i])); end; procedure TForm1.Button2Click(Sender: TObject); var i,j,x: integer; z2: Bereich; begin listbox2.clear; z2 := z; for i := 1 to Anzahl-1 do for j := i+1 to Anzahl do if Z2[j] < Z2[i] then begin x := Z2[j]; Z2[j] := Z2[i]; Z2[i] := x; end; for i := 1 to Anzahl do Listbox2.Items.Add(inttostr(Z2[i])); end; end.