I've been having trouble generating random integers with the example provided by user @Cubbi on this question. I've set up the program as follows:
rand_test.cpp
#include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::mt19937 eng(rd());
std::uniform_int_distribution<> distr(25, 63);
for(int n = 0; n < 40; ++n)
std::cout << distr(eng) << ' ';
}
...and compiled it with g++ rand_test.cpp -std=c++11
I executed the program four times in the span of about a minute and received the exact same sequence of numbers:
46 53 38 60 25 48 59 45 62 63 31 50 37 45 52 55 34 27 ...
I then executed it again after researching the issue and beginning this question (10-15 minutes) and again, the same output. Then I recompiled, and the output was the same as before. What's the cause and how do I fix this?
- Compiler: TDM-GCC-64
- OS: Windows 10 Home (64 bit)
Aucun commentaire:
Enregistrer un commentaire