12345678910111213141516
#include <iostream> #include <random> #include <ctime> int random_value_in_range( int minval, int maxval ) // C++11 { // http://en.cppreference.com/w/cpp/numeric/random static std::mt19937 rng( std::time(nullptr) ) ; return std::uniform_int_distribution<int>( minval, maxval )(rng) ; } int main() { for( int i = 0 ; i < 30 ; ++i ) std::cout << random_value_in_range( 50, 100 ) << ' ' ; std::cout << '\n' ; }