c 2b 2b uniform real distribution get same result

Solutions on MaxInterview for c 2b 2b uniform real distribution get same result by the best coders in the world

showing results for - "c 2b 2b uniform real distribution get same result"
Fynn
06 Feb 2020
1//don't use a time based seed, you could use std::random_device like this:
2// Create a random device and use it to generate a random seed
3std::random_device myRandomDevice;
4unsigned int seed = myRandomDevice(); //generate a random seed
5
6std::uniform_real_distribution<double> dist(-1.0, 1.0); //will be from -1 to 1
7double randomNumber = dist(seed); //now you get random numbers