Lottery question
Lottery question
How would you write a program that randomly generates a lottery pick automatically based on the following restrictions:
1. Each pick consists of 6 lottery numbers.
2. Lottery numbers must be between 1 through 50
3. All six lottery numbers must be unique within any pick.
1. Each pick consists of 6 lottery numbers.
2. Lottery numbers must be between 1 through 50
3. All six lottery numbers must be unique within any pick.
- Seb McClouth
- Veteran
- Posts: 342
- Joined: Wed Nov 09, 2005 7:47 am
- Location: Inside the Matrix...
- Contact:
Re: Lottery question
I would try to write something... listen to my teacher... listen to my teacher... and listen to my teacher... if it still sucks... I'd post it here... ask ppl to check it out...How would you do a lotto? wrote:How would you write a program that randomly generates a lottery pick automatically based on the following restrictions:
1. Each pick consists of 6 lottery numbers.
2. Lottery numbers must be between 1 through 50
3. All six lottery numbers must be unique within any pick.
Oh and do ask my teacher about it...
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
Here you go dude!
Code: Select all
CLS
RANDOMIZE TIMER
num=0
numa=0
numb=0
numc=0
numd=0
nume=0
do
num=int(rnd*50+1)
loop until num<>numa and num<>b and num<>numc and num<>numd and num<>nume
''now do this 6 times and replace num with numa, then numb, then numc, etc, and change the num<>whatever to numa<>whatever, numb<>whatever,etc, and make sure
''not do do numa<>numa, numb<>numb, etc
Lottery question
thank you?
welcome
welcome
Code: Select all
RANDOMIZE TIMER
DIM thelist(50) AS INTEGER
DIM picks(6) AS INTEGER
FOR aaa = 1 TO 6
repeat: bbb = INT(RND * 50) + 1
IF thelist(bbb) = 1 THEN GOTO repeat
thelist(bbb) = 1
NEXT aaa
ccc = 0
FOR aaa = 1 TO 50
IF thelist(aaa) = 1 THEN
ccc = ccc + 1: picks(ccc) = aaa
END IF
NEXT aaa
FOR aaa = 1 TO 6
PRINT picks(aaa);
NEXT aaa
PRINT
system
i am trapped in the hell.