Lottery question

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
How would you do a lotto?

Lottery question

Post by How would you do a lotto? »

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.
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

I would listen to my teacher, then read the textbook..

Ya.. that's what I'd do..
I have left this dump.
User avatar
Deleter
Veteran
Posts: 119
Joined: Sat May 07, 2005 7:31 pm

Post by Deleter »

Z!re wrote:I would listen to my teacher, then read the textbook..

Ya.. that's what I'd do..
I would go straight to reading the textbook, personally...but in general thats good advice. :)
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

^^ I would quit the class...
Image
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Re: Lottery question

Post by Seb McClouth »

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.
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...

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.
PQBC says 'Hi!'

Post by PQBC says 'Hi!' »

Z!re:
1. Is he a user that comes often?
2. Where did you get that avatar and why?
QBGV

Here you go dude!

Post by QBGV »

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
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

PQBC says 'Hi!' wrote:Z!re:
1. Is he a user that comes often?
2. Where did you get that avatar and why?
1. No
2. A warcraft III: the frozen throne custom minimap
I have left this dump.
Atrapado
Newbie
Posts: 3
Joined: Thu Dec 01, 2005 10:49 am
Location: Mexico

Lottery question

Post by Atrapado »

thank you?
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.
Post Reply