Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i need some help
#11
Quote:that's why he has INT(RND *50) + 1

Well removing the "INT" and you can get 500+ numbers without
repeating or overrule the "highest value limit"
/post]
Reply
#12
I think he meant that no identical number may follow each other, so that it is possible to get this: 1212121212121212. But no: 1221122112211. That would make it possible to get 56 random numbers out of 50.
Reply
#13
Quote:
potato Wrote:
pvera11 Wrote:im new to qb. my assignment is to create a lottery program that picks 56 random non repeating numbers from 1 to 50 inclusive.

Is that possible? I thought there were only 50 numbers from 1-50 inclusive! How can you pick the extra 6# and not have them repeat?

PVERA: What do you have to say about this? Sounds like the problem specs are faulty. You can't proceed without clearing this up. You asked for help, remember. We can't help if the specs don't make sense.
*****

Come on guys! This is obviously a case of him pressing the "6" key but also accidentily pressing the "5" too, and not proofreading! Use your brains! Of course he means just "6".
Reply
#14
what if he means 5? or even 4 and has a fat finger? or maybe he means....
ammit potato!
Reply
#15
:roll: How many balls are usually in a lottery?
Reply
#16
There's pick-10, 5, and eight in my area. Six also, but I don't know anyone who plays that ;D
ammit potato!
Reply
#17
i ended up using some gosubs and for statements

cls
start:
dim num(6)
gosub generate
num(1) = rand
for count = 2to6
gosub generate
for count2 = 1 to (count -1)
if rand=num(count2) then
goto start
end if
next count2
num(count)=rand
next count
for count=1to6
print num(count); " ";
next count print

do
if inkey$ = ch$(13) then
goto start
end if
loop

generate:
upper=50
lower=1
rand=int(rnd*50)+1
return


this codes alot better than the long one i had b4, only it kinda works slow...any suggestions?


pvera11
Reply
#18
You could do it two ways. Generate random numbers and check all the other ones before it, or create a 50-number array filled with 1,2,3,4,etc. swap them around, and use the first 6 (or whatever you need).

Like this: (I'm just using the SHARED because you might want to use it in another sub, dunno. Doesn't hurt.)

Code:
DIM SHARED num%(1 TO 50) '(50) is (0 TO 50)..

FOR i% = 1 to 50
num%(i%) = i%
NEXT i%

FOR i% = 1 to 50 'you can mix them up as much as you want
rnd1% = INT(RND * 50) + 1
rnd2% = INT(RND * 50) + 1
SWAP num%(rnd1%), num%(rnd2%)
NEXT i%

FOR i% = 1 to 6
PRINT num%(I%)
NEXT I%
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#19
Oh, I forgot to initialize the values, so right now it's just swapping zeroes around. Silly me. Fixing it..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#20
http://www.network54.com/Hide/Forum/thre...1062799714

Other goodies are found at
http://www.network54.com/Hide/Index/10167

Mac
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)