Advertisement
Guest User

Untitled

a guest
Jul 9th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
DIV 1.76 KB | None | 0 0
  1. var
  2.  
  3. Lotto : Array[0..49] of integer;
  4. Lotto1 : Array[0..49] of integer;
  5. i,j,x,y,hilf,q,k,wert,min,n : integer;
  6. fertig : boolean;
  7. procedure TForm1.Button1Click(Sender: TObject);
  8.  
  9. BEGIN
  10. randomize;
  11. Listbox1.Clear;
  12. FOR i:= 1 TO 49 do
  13. BEGIN
  14. Lotto[i] := i;
  15. END;
  16.  
  17. FOR q:=1 TO 300 do
  18. BEGIN
  19. x:= random(48) +1;
  20. y:= random(48) +1;
  21. hilf := Lotto[x];
  22. Lotto[x] := Lotto[y];
  23. Lotto[y] := hilf;
  24. END;
  25.  
  26. FOR i:=1 TO 6 do
  27. BEGIN
  28. Listbox1.Items.add(inttostr(Lotto[i]));
  29. Lotto1[i] := Lotto[i];
  30. END;
  31.  
  32. END;
  33.  
  34. procedure TForm1.Button2Click(Sender: TObject);
  35. BEGIN
  36. Listbox1.Clear;
  37. CASE RadioGroup1.ItemIndex of
  38. 0:BEGIN
  39. Bubble();
  40. END;
  41. 1:BEGIN
  42. Selection();
  43. END;
  44. 2:BEGIN
  45. Insertion();
  46. END;
  47. END;
  48.  
  49. FOR i :=1 TO 6 do
  50. BEGIN
  51. listbox1.Items.Add(inttostr(Lotto1[i]));
  52. END;
  53.  
  54. END;
  55.  
  56.  
  57.  
  58. procedure TForm1.Button3Click(Sender: TObject);
  59. BEGIN
  60. close;
  61. END;
  62.  
  63. procedure Bubble();
  64. BEGIN
  65. fertig := false;
  66. j := 6;
  67.     WHILE NOT fertig do
  68.     BEGIN
  69.     fertig:= true;
  70.     FOR k:= 1 TO j-1 do
  71.     BEGIN
  72.       IF (Lotto1[k] > Lotto1[k+1]) then
  73.       BEGIN
  74.       hilf := Lotto1[k] ;
  75.       Lotto1[k] := Lotto1[k+1];
  76.       Lotto1[k+1] := hilf;
  77.       fertig := false;
  78.       END;
  79.     END;
  80.     END;
  81. END;
  82.  
  83. procedure   Insertion();
  84. BEGIN
  85. FOR i := 2 TO 6 do
  86.     IF (Lotto1[i] < Lotto1[i - 1]) then
  87.     BEGIN
  88.       wert := Lotto1[i];
  89.       j := i;
  90.       WHILE ((j > 1) AND (Lotto1[j-1 ] > Wert)) do
  91.       BEGIN
  92.         Lotto1[j] := Lotto1[j - 1];
  93.         j := j -1;;
  94.       END;
  95.       Lotto1[j] := Wert;
  96.     END;
  97. END;
  98.  
  99. procedure Selection();
  100. BEGIN
  101. k:=0;
  102. n := 6;
  103. WHILE k < n do
  104. BEGIN
  105. min:= k;
  106. FOR i:=k+1 TO n-1 do
  107. BEGIN
  108. IF Lotto1[i] < Lotto1[min] then
  109. BEGIN
  110. min:=i;
  111. END;
  112. END;
  113. hilf:=Lotto1[k];
  114. Lotto1[k]:=Lotto1[min];
  115. Lotto1[min]:=hilf;
  116. k:=k+1;
  117. END;
  118. END;
  119. END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement