©
serviceprofessionalgmbh
The starting point: A program is expected to come up with 6 to 12 numbers between 1 and 49.
None of the selected numbers is allowed to be chosen twice.
Should the randomiser produce a number which has been already drawn, the random selection will be repeated until a
new unique number comes up.
A simple task. A loop for the randomiser. Checking for duplicate numbers. If all OK, increase draw counter.
Otherwise recall randomiser.
In many REXX seminars over 90% of the participants came up with a solution like this.
/* 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
var.=0
x=1
do forever
if x > anz then leave
z=random(1,49)
fehl=0
if x > 1 then do y=1 to x /* Pruefen doppelter Zahlen */
if var.y = z then fehl=1
end
var.x=z
if fehl=0 then x=x+1
end
do x=1 to 49 /* Sortierte Zahlenausgabe */
do y=1 to anz
if x=var.y then say centre(var.y,79)
end
end
say
say center('Viel Erfolg',79,'-')
exit
back to Fun & More