Could someone help me with generating random numbers between 0-72 while also guarantee it WILL cover all numbers from 0 to 72 inclusively?
I have tried the following, but some numbers appear more than once and some don't appear at all.
int max= 71;
int min= 0;
std::random_device engine;
//initialise to -1 to make sure numbers are generated and stored properly
int randomNum = -1;
while(max> 0){
std::uniform_int_distribution<int> randomDistributed(min,max);
randomNum = randomDistrubuted(engine);
std::cout << randomNum << ", ";
max--;
}
Aucun commentaire:
Enregistrer un commentaire