|
From: Per W. <pw...@ia...> - 2003-06-18 21:47:37
|
Note that rand()%x is not a good way of generating truly random numbers. The pseudo-random numbers generated by most implementations of rand() have bad randomness of the low bits. There are a lot of cryptographic libraries with good random number generators. /Per W On Thu, 19 Jun 2003, Abhijit Shylanath wrote: > > Greets, Artificial Stupidity, I'm Real Happy (to meet you). > > > HI, does anyone know a good way to use rnd() to generate non-repeating > random numbers - in the area of about a thousand. > > rand()%1000; // Gives a number from 0 - 999 > > Also, at the beginning of the program, do > > srand(time(NULL)); > > This is to initialize (seed) the random number so that you get different > sequences everytime you run the program. > > HTH. > ________________________________________ > > Abhijit Shylanath > http://mudeth.tripod.com/ > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: INetU > Attention Web Developers & Consultants: Become An INetU Hosting Partner. > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |