Advertisement
Guest User

Untitled

a guest
May 5th, 2010
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. var
  2. Form1: TForm1;
  3. nahodne:array[1..5]of integer;
  4. i,a,b,c,d,e,vklad,vysledok,cena:integer;
  5. implementation
  6.  
  7. {$R *.dfm}
  8.  
  9. procedure TForm1.FormCreate(Sender: TObject);
  10. begin
  11. vysledok:=0;
  12. a:=strtoint(edit1.text);
  13. b:=strtoint(edit2.text);
  14. c:=strtoint(edit3.text);
  15. d:=strtoint(edit4.text);
  16. e:=strtoint(edit5.text);
  17. vklad:=strtoint(edit6.text);
  18. memo1.Lines.add('Hraj loto!');
  19. memo1.Lines.add('Zadaj do prazdnych policok 5 roznych cisiel a do posledneho vklad(v korunach)');
  20. end;
  21.  
  22. procedure TForm1.Button1Click(Sender: TObject);
  23. begin
  24. for i:=1 to 5 do nahodne[i]:=random(20)+1;
  25. repeat
  26. nahodne[1]:=random(20)+1;
  27. nahodne[2]:=random(20)+1;
  28. nahodne[3]:=random(20)+1;
  29. nahodne[4]:=random(20)+1;
  30. until (nahodne[1]<>nahodne[2]) and (nahodne[1]<>nahodne[3]) and (nahodne[1]<>nahodne[4]) and (nahodne[1]<>nahodne[5]) and (nahodne[2]<>nahodne[3]) and (nahodne[2]<>nahodne[4]) and (nahodne[2]<>nahodne[5]) and (nahodne[3]<>nahodne[4]) and (nahodne[3]<>nahodne[5]) and (nahodne[4]<>nahodne[5]);
  31.  
  32. memo1.Lines.add('Vylosovane cisla:');
  33. memo1.Lines.add(inttostr(nahodne[1]));
  34. memo1.Lines.add(inttostr(nahodne[2]));
  35. memo1.Lines.add(inttostr(nahodne[3]));
  36. memo1.Lines.add(inttostr(nahodne[4]));
  37. memo1.Lines.add(inttostr(nahodne[5]));
  38. for i:=1 to 5 do
  39. begin
  40. if nahodne[i]=a then inc(vysledok);
  41. if nahodne[i]=b then inc(vysledok);
  42. if nahodne[i]=c then inc(vysledok);
  43. if nahodne[i]=d then inc(vysledok);
  44. if nahodne[i]=e then inc(vysledok);
  45. end;
  46. memo1.lines.add(inttostr(vysledok));
  47. case vysledok of
  48. 0: memo1.lines.add('lutujem nevyhravas');
  49. 1:
  50. begin
  51. cena:=round(vklad*(1/5));
  52. memo1.lines.add('vyhravas '+inttostr(cena));
  53. end;
  54. 2:
  55. begin
  56. cena:=2*round(vklad*(2/5));
  57. memo1.lines.add('vyhravas '+inttostr(cena));
  58. end;
  59. 3:
  60. begin
  61. cena:=3*round(vklad*(3/5));
  62. memo1.lines.add('vyhravas '+inttostr(cena));
  63. end;
  64. 4:
  65. begin
  66. cena:=4*round(vklad*(4/5));
  67. memo1.lines.add('vyhravas '+inttostr(cena));
  68. end;
  69. 5:
  70. begin
  71. cena:=5*vklad;
  72. memo1.lines.add('vyhravas '+inttostr(cena));
  73. end;
  74. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement