jeudi 25 octobre 2018

uniform_int_distribution return a number form outside the range

I am trying to implement a simple quicksort algorithm. It starts with f.e. two randomly selected numbers, p and r. I do get them like this:

std::random_device rd;
std::mt19937 rng(rd());
std::uniform_int_distribution<> urd(0, 10);
int p = urd(rng);
int r = urd(rng);
std::cout << p << ' ' << r << '/n';

The problem is, I get the result:

3 11214210

And its not constant. It varies. The first number is always in range of (0,10). And the second number is, well, kinda too big

And then the array (for now of fixed size of 10), printed out, looks like this:

[31129611129621129671129641129661129651129681129691129610]

Do you guys know what am I doing wrong?




Aucun commentaire:

Enregistrer un commentaire