Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- Lotto : Array[0..49] of integer;
- Lotto1 : Array[0..49] of integer;
- i,j,x,y,hilf,q,k,wert,min,n : integer;
- fertig : boolean;
- procedure TForm1.Button1Click(Sender: TObject);
- BEGIN
- randomize;
- Listbox1.Clear;
- FOR i:= 1 TO 49 do
- BEGIN
- Lotto[i] := i;
- END;
- FOR q:=1 TO 300 do
- BEGIN
- x:= random(48) +1;
- y:= random(48) +1;
- hilf := Lotto[x];
- Lotto[x] := Lotto[y];
- Lotto[y] := hilf;
- END;
- FOR i:=1 TO 6 do
- BEGIN
- Listbox1.Items.add(inttostr(Lotto[i]));
- Lotto1[i] := Lotto[i];
- END;
- END;
- procedure TForm1.Button2Click(Sender: TObject);
- BEGIN
- Listbox1.Clear;
- CASE RadioGroup1.ItemIndex of
- 0:BEGIN
- Bubble();
- END;
- 1:BEGIN
- Selection();
- END;
- 2:BEGIN
- Insertion();
- END;
- END;
- FOR i :=1 TO 6 do
- BEGIN
- listbox1.Items.Add(inttostr(Lotto1[i]));
- END;
- END;
- procedure TForm1.Button3Click(Sender: TObject);
- BEGIN
- close;
- END;
- procedure Bubble();
- BEGIN
- fertig := false;
- j := 6;
- WHILE NOT fertig do
- BEGIN
- fertig:= true;
- FOR k:= 1 TO j-1 do
- BEGIN
- IF (Lotto1[k] > Lotto1[k+1]) then
- BEGIN
- hilf := Lotto1[k] ;
- Lotto1[k] := Lotto1[k+1];
- Lotto1[k+1] := hilf;
- fertig := false;
- END;
- END;
- END;
- END;
- procedure Insertion();
- BEGIN
- FOR i := 2 TO 6 do
- IF (Lotto1[i] < Lotto1[i - 1]) then
- BEGIN
- wert := Lotto1[i];
- j := i;
- WHILE ((j > 1) AND (Lotto1[j-1 ] > Wert)) do
- BEGIN
- Lotto1[j] := Lotto1[j - 1];
- j := j -1;;
- END;
- Lotto1[j] := Wert;
- END;
- END;
- procedure Selection();
- BEGIN
- k:=0;
- n := 6;
- WHILE k < n do
- BEGIN
- min:= k;
- FOR i:=k+1 TO n-1 do
- BEGIN
- IF Lotto1[i] < Lotto1[min] then
- BEGIN
- min:=i;
- END;
- END;
- hilf:=Lotto1[k];
- Lotto1[k]:=Lotto1[min];
- Lotto1[min]:=hilf;
- k:=k+1;
- END;
- END;
- END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement