Is it modern C++ to use srand to set random seed?

后端 未结 3 1693
慢半拍i
慢半拍i 2021-02-13 05:07

For code that uses std::random_shuffle, I need to set a random seed so that the pseudorandom sequences produced vary in each program run.

The code example h

3条回答
  •  独厮守ぢ
    2021-02-13 05:29

    If you are using C++11, think about using std::shuffle instead of std::random_shuffle, and passing a random-number generator, as in the last example here

提交回复
热议问题