| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: c++ help |
From: "Geo"
"Paul Ranson" wrote in message
news:41b34f56{at}w3.nls.net...
>>I don't think that your 'for i' stuff helps you. Why not just seed the
generator once at program start?
I tried that but it's a GUI app and the seed doesn't seem to be global to
the member function that's calling rand().
>>m_pick3.Format ( "%d-%d-%d", rand () % 10, rand () % 10,
rand () % 10 ) ;
Ohhhh.. I like that. Works great for pick3 and pick4 since those are all 1
digit numbers. Now I'm trying to do super lotto which requires 6 two digit
numbers. I can do it the same way
m_pick5.Format ("%d-%d-%d-%d-%d", rand()%50, rand()%50,
rand()%50, rand()%50, rand()%50, rand()%50) ;
but that allows duplicates, I could end up with 21-1-21-21-2-21
so this one is going to require some checking for duplicates (probably
using variables) before converting them to a string with "-"
separators. I'm working on that one now but would appreciate any ideas.
Your code is so much more elegant than my brutal stuff.
Oh and as for the not being random, it is as long as you can't time travel
or pick twice during the same second.. (well it appears random
anyway, who's to say if anything is *really* random and not just beyond our
understanding)
Geo.
--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)SEEN-BY: 633/267 270 5030/786 @PATH: 379/45 1 396/45 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.