📌  相关文章
📜  c++ uniform_real_distribution 得到相同的结果 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:52.738000             🧑  作者: Mango

代码示例1
//don't use a time based seed, you could use std::random_device like this:
// Create a random device and use it to generate a random seed
std::random_device myRandomDevice;
unsigned int seed = myRandomDevice(); //generate a random seed

std::uniform_real_distribution dist(-1.0, 1.0); //will be from -1 to 1
double randomNumber = dist(seed); //now you get random numbers