jeudi 30 avril 2020

uniform_int_distribution giving the same number even when seeded with random_device [duplicate]

Straight forward, this is my simple example:

#include <iostream>
#include <random>

int main()
{
    std::random_device rd;
    std::mt19937 mt(rd());
    std::uniform_int_distribution<int> dist(0,100);

    std::cout << dist(mt) << std::endl;
    return 0;
}

Every time I run the program, it gives the same answer: 56

This code should output a random number each time, but it doesn't... why?




Aucun commentaire:

Enregistrer un commentaire