📅  最后修改于: 2022-03-11 14:44:48.845000             🧑  作者: Mango
/*The problem with srand(time(NULL)) and rand() is that if you use them
in a loop it'll probably be executed during the same clock period
and therefore rand() will return the same number. To solve this
you can use the library random to help you.*/
#include
std::random_device rd;
std::mt19937 e{rd()};
std::uniform_int_distribution dist{1, 5}; //Limits of the interval
//Returns a random number between {1, 5} with
dist(e);