example1_basic_usage.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include <iostream>
#include <random>

int main() {
    std::random_device rd;  // Used to seed the engine
    std::mt19937 gen(rd()); // Mersenne Twister engine
    std::uniform_int_distribution<> distrib(1, 6); // Distribution for integers 1 to 6

    for (int i = 0; i < 10; ++i) {
        std::cout << distrib(gen) << " ";
    }
    std::cout << std::endl;

    return 0;
}
Back to random