How do I generate a random number using the C++11 standard library

后端 未结 7 1196
遇见更好的自我
遇见更好的自我 2020-12-05 05:34

The new C++11 Standard has a whole chapter dedicated to random number generators. But how do I perform the simplest, most common task that used to be coded like this, but wi

相关标签:
7条回答
  • 2020-12-05 05:56

    You could use RC4 to generate random bytes. This probably has the properties that you want. It is fast and fairly simple to implement. The sequence is repeatable across all implementations when the seed is known, and completely unpredictable when the seed is not known. http://en.wikipedia.org/wiki/RC4

    0 讨论(0)
提交回复
热议问题