xxxxxxxxxx
min + ( std::rand() % ( max - min + 1 ) )
xxxxxxxxxx
int random(int min, int max) {
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> gen(min, max);
int a = gen(rng);
return a;
}
xxxxxxxxxx
#include <iostream>
#include <random>
int main()
{
std::random_device rd; // obtain a random number from hardware
std::mt19937 gen(rd()); // seed the generator
std::uniform_int_distribution<> distr(25, 63); // define the range
for(int n=0; n<40; ++n)
std::cout << distr(gen) << ' '; // generate numbers
}