©
serviceprofessionalgmbh
Imagine the following scenario at the draw of the Lottery: As soon as the ball leaves the lottery drum,
the lottery girl announces:
'...the forth Number is... STOP. Ladies and Gentlemen, I need to check first whether the forth number is identical with
the first, second or third number. If so, I need to put it back in the lottery drum.'
A funny thought but never heard of in real life so far. Obviously there must be a solution to this problem which manages
completely without checks and ensures that no duplicates are drawn. Life rules this out by removing the drawn number from
the lottery drum. Just like this we want to handle this problem in our program:
/* REXX
*/
arg anz
do while anz < 6 ! anz > 12
say 'Anzahl zu ziehender Zahlen (6 bis 12):'
pull anz
end
say
say center("Lotto" anz "aus 49",79,'-')
say
kugeln=""
do idx=1 to 49
kugeln=kugeln" "idx
end
do idx=1 to anz
rnd=random(1,words(kugeln))
var.idx=word(kugeln,rnd)
kugeln=delword(kugeln,rnd,1)
end
zahlausg=""
do x=1 to 49 /* Sortierte Zahlenausgabe */
do y=1 to anz
if x=var.y then zahlausg=zahlausg" "var.y
end
end
say center(zahlausg,79)
say
say center('Viel Erfolg',79,'-')
exit
back to Fun & More