random number
-
Hello, I want to ask how to generate a random number which is lie between 0 and n, and they are evenly distributed (i.e. all number have the same probability). Calvin thx!!! :-D:omg::rolleyes:
-
Why dont u use : srand ( time ( NULL ) ) ; int RandomNumber = rand () % (n + 1) ; Papa while (TRUE) Papa.WillLove ( Bebe ) ;
oops, misread the question. Michel It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard -
Hello, I want to ask how to generate a random number which is lie between 0 and n, and they are evenly distributed (i.e. all number have the same probability). Calvin thx!!! :-D:omg::rolleyes:
For a reasonably good random number generator you might want to have a look at the source for dev/random from the Linux sources (
rand()
from e.g the MS CRT will get you nowhere near randomness).