program turistid_kohvikus; label uuesti; var kohvik, pro, i, tur_paaridearv, uturist1, uturist2, vturist1, vturist2, q, turist1,turist2:integer; begin randomize; tur_paaridearv:=random(1000); kohvik:=0; for i:=1 to tur_paaridearv do begin vturist1:=0; vturist2:=0; turist1:=1; turist2:=1; uuesti: q:=random(4); if ((turist1=5) or (turist1=9) or (turist1=13) or (turist1=17)) and (q=1) then goto uuesti; if ((turist1=4) or (turist1=8) or (turist1=12) or (turist1=16)) and (q=0) then goto uuesti; if ((turist2=5) or (turist2=9) or (turist2=13) or (turist2=17)) and (q=1) then goto uuesti; if ((turist2=4) or (turist2=8) or (turist2=12) or (turist2=16)) and (q=0) then goto uuesti; if ((turist1=17) or (turist1=18) or (turist1=19) or (turist1=20)) and (q=2) then goto uuesti; if ((turist2=17) or (turist2=18) or (turist2=19) or (turist2=20)) and (q=2) then goto uuesti; if ((turist1=2) or (turist1=3) or (turist1=4)) and (q=3) then goto uuesti; if ((turist2=2) or (turist2=3) or (turist2=4)) and (q=3) then goto uuesti; if q=0 then uturist1:=turist1+1; if q=0 then uturist2:=turist2+1; if q=1 then uturist1:=turist1-1; if q=1 then uturist2:=turist2-1; if q=2 then uturist1:=turist1+4; if q=2 then uturist2:=turist2+4; if q=3 then uturist1:=turist1-4; if q=3 then uturist2:=turist2-4; if (uturist1<>turist1) and (uturist1<21) and (uturist1>0) and (uturist2<>turist2) and (uturist2<21) and (uturist2>0) then begin vturist1:=turist1; vturist2:=turist2; turist1:=uturist1; turist2:=uturist2; end; if (turist1<>11) and ((turist1<>1) or (turist1=0)) and(turist2<>11) and ((turist2<>1) or (turist2=0)) then goto uuesti; if (turist1=11) and (turist2=11) then kohvik:=kohvik+1; end; pro:=round((kohvik/tur_paaridearv)*100); writeln('Kaks turisti jäuavad korraga kohvikusse ',kohvik,' korral ', tur_paaridearv,'-st, seega ',pro,'%.'); readln; end.