📅  最后修改于: 2022-03-11 14:44:55.254000             🧑  作者: Mango
#include
#include
int main() {
// 1. The random device
std::random_device rd;
// 2. The "Mersenne Twister" random engine
std::mt19937 gen(rd());
// 3. A random distribution
std::uniform_int_distribution dist(1, 20);
for (int i = 0; i < 10; i ++) {
std::cout << dist(gen) << " ";
}
std::cout << "\n";
}
Output:
16 8 11 9 9 13 9 4 13 9