Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- Form1: TForm1;
- nahodne:array[1..5]of integer;
- i,a,b,c,d,e,vklad,vysledok,cena:integer;
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- vysledok:=0;
- a:=strtoint(edit1.text);
- b:=strtoint(edit2.text);
- c:=strtoint(edit3.text);
- d:=strtoint(edit4.text);
- e:=strtoint(edit5.text);
- vklad:=strtoint(edit6.text);
- memo1.Lines.add('Hraj loto!');
- memo1.Lines.add('Zadaj do prazdnych policok 5 roznych cisiel a do posledneho vklad(v korunach)');
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- for i:=1 to 5 do nahodne[i]:=random(20)+1;
- repeat
- nahodne[1]:=random(20)+1;
- nahodne[2]:=random(20)+1;
- nahodne[3]:=random(20)+1;
- nahodne[4]:=random(20)+1;
- 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]);
- memo1.Lines.add('Vylosovane cisla:');
- memo1.Lines.add(inttostr(nahodne[1]));
- memo1.Lines.add(inttostr(nahodne[2]));
- memo1.Lines.add(inttostr(nahodne[3]));
- memo1.Lines.add(inttostr(nahodne[4]));
- memo1.Lines.add(inttostr(nahodne[5]));
- for i:=1 to 5 do
- begin
- if nahodne[i]=a then inc(vysledok);
- if nahodne[i]=b then inc(vysledok);
- if nahodne[i]=c then inc(vysledok);
- if nahodne[i]=d then inc(vysledok);
- if nahodne[i]=e then inc(vysledok);
- end;
- memo1.lines.add(inttostr(vysledok));
- case vysledok of
- 0: memo1.lines.add('lutujem nevyhravas');
- 1:
- begin
- cena:=round(vklad*(1/5));
- memo1.lines.add('vyhravas '+inttostr(cena));
- end;
- 2:
- begin
- cena:=2*round(vklad*(2/5));
- memo1.lines.add('vyhravas '+inttostr(cena));
- end;
- 3:
- begin
- cena:=3*round(vklad*(3/5));
- memo1.lines.add('vyhravas '+inttostr(cena));
- end;
- 4:
- begin
- cena:=4*round(vklad*(4/5));
- memo1.lines.add('vyhravas '+inttostr(cena));
- end;
- 5:
- begin
- cena:=5*vklad;
- memo1.lines.add('vyhravas '+inttostr(cena));
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement