![]() |
|
#1
|
|||
|
|||
Random() : Make each number onlu appear onceForst of all sorry about the empty post, /n you know
I have a sort of dumb a question. I have tried to solv a problem for a "while" now, without any progress. Newbeeish as I am, only small meaningless programs are the fruits of my labour (wierd sentence). For once I am trying to build something bigger, a quiz actually. The thing is; the questions are choosed randomly, but not that "well"... The same numbers are picked once in awhile, resulting in the same questions beeing asked (in the same session). I have tried avoiding this by adding the allreaddy-picked numbers to an array or a vector, and then making the computer check these "registers". If the number is used => generate a new number. My lack of syntax- and C++- knowledge are the problem CPP / C++ / C Code:
|
|
#2
|
|||
|
|||
|
The definition of a 'perfect' random number generator, is one which never repeats a number! But how do introduce a unpredictable element into the definate logic of a computer? Computer's generators are all pseudo, based on very funky math, and a 'seed' - but repetitions do occur.
You need a seed to make it even more random! You seed it using the srand(int) function, and pass it something unpredictable (the time is good) by srand( time(NULL) ). But your biggest problem is that you've so few options to choose from. Write yourself a quick program printing the randon number mod 32 a few times, and you'll see the same number will come up a few times. GF |
|
#3
|
|||
|
|||
|
Quote:
http://www.cryptography.com/resource...s/IntelRNG.pdf (ref. top of column 2 on page 1) random != unique |
|
#4
|
|||
|
|||
|
I was thinking about that after I wrote it, and you're correct. A purely random number generator is one by which there is an equal probabillity of each number to appear. Statistically, randomness fits the bell curve, so repetitions are allowed. Apologies
GF |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to find the last 6 digits of a 8 digit number? | rjd72285 | C++ Forum | 3 | 28-Oct-2003 08:21 |
| Need a script for selecting random tabels and from those tabels selecting random ques | mlt | MySQL / PHP Forum | 2 | 12-Sep-2003 09:01 |
| auto number | skyloon | MySQL / PHP Forum | 1 | 30-Jun-2003 08:33 |
| Random no longer JUST random... | JdS | GIDTopsites™ | 0 | 12-Jan-2003 08:57 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The