random_shuffle algorithm - are identical results produced without random generator function?

前端 未结 3 1082
青春惊慌失措
青春惊慌失措 2021-01-13 00:07

If a random generator function is not supplied to the random_shuffle algorithm in the standard library, will successive runs of the program produce the same random sequence

3条回答
  •  感情败类
    2021-01-13 00:51

    You may produce an identical result every run of the program. You can add a custom random number generator (which can be seeded from an external source) as an additional argument to std::random_shuffle if this is a problem. The function would be the third argument. Some people recommend call srand(unsigned(time(NULL))); before random_shuffle, but the results are often times implementation defined (and unreliable).

提交回复
热议问题