I get a task to generate tens of thousands random number in c++. I've googled a lot about random number in c++ and look up the c++ reference, but I got confused now.
As I know, random_device is a non-deterministic random number generator, but every time I re-run my program, the random number generated by random_device is the same. So how do I set a seed for random_device to make the random number is different when I restart my program?
And I've read that "std::random_device could run out of entropy if you try to get a lot of numbers from it. That could cause it to block until you move the mouse or something". That means my program could pause at some time. How can I avoid this happening?
Aucun commentaire:
Enregistrer un commentaire