#include <random>
#include <iostream>
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<int> dist(1, 20);
for (int i = 0; i < 10; i ++) {
std::cout << dist(gen) << " ";
}
std::cout << "
";
}
Output:
16 8 11 9 9 13 9 4 13 9