uses Crt, Dos; const T = 500; { cekaci cas [s/100] } CenaListku = 6; var UvnitrKc : longint; Ch : char; H, M, S, S100 : word; CasNaZac, Cas, Doba : longint; procedure Vypis; begin ClrScr; WriteLn ('V automatu : ',UvnitrKc,',- Kc'); WriteLn; WriteLn ('Vhod minci : '); WriteLn ('-------------'); WriteLn ('1. 1,- Kc'); WriteLn ('2. 2,- Kc'); WriteLn ('3. 5,- Kc'); WriteLn ('4. 10,- Kc'); WriteLn ('5. 20,- Kc'); WriteLn; end; function ZPismenPrachy (Znak : char) : byte; begin case Znak of '1' : ZPismenPrachy := 1; '2' : ZPismenPrachy := 2; '3' : ZPismenPrachy := 5; '4' : ZPismenPrachy := 10; '5' : ZPismenPrachy := 20; else ZPismenPrachy := 0; end; end; begin UvnitrKc := 0; Vypis; { vsechno zacne az po stlaceni spravne klavesy } repeat Ch := ReadKey; if Ch = #0 then ReadKey; {pokud je klavesa nestandardni -> nezajima nas} until Ch in ['1'..'5']; repeat UvnitrKc := UvnitrKc + ZPismenPrachy (Ch); Vypis; Ch := #255; GetTime (H, M, S, S100); CasNaZac := S100 + S*100 + M*60*100 + H*3600*100; repeat GetTime (H, M, S, S100); Doba := S100 + S*100 + M*60*100 + H*3600*100 - CasNaZac; GoToXY (2,12); WriteLn ('Doba prodlevy : ',Doba div 100,' s '); if KeyPressed then begin Ch := ReadKey; if Ch = #0 then ReadKey; {pokud je klavesa nestandardni -> nezajima nas} end; until (Ch in ['1'..'5']) or (Doba > T); until (Doba > T) and (UvnitrKc > CenaListku); WriteLn; WriteLn ('Pocet listku : ',UvnitrKc div CenaListku); WriteLn ('Vracene penize : ',UvnitrKc mod CenaListku,',- Kc'); end.