jeudi 14 octobre 2021

Can i exclude a number or subrange of numbers inside a range of random numbers in modern C++?

I have:

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

I want to exclude some numbers in this range of probabilities.
Example1: Let's say, I want to generate a random number in between 0 and 100, but this number can never be 4.
Example2: Let's say, I want to generate a random number in between 0 and 100, but this number can never be any number between 4 and 7.

I wonder if it is possible to achieve in modern C++ without using std::rand?
Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire