Created
July 5, 2018 21:31
-
-
Save MannyGozzi/2cc453717b00a7555404acafee600e4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <random> | |
static unsigned long long genRandRange(unsigned int min, unsigned int max) | |
{ | |
//create random number engine | |
std::mt19937_64 engine; | |
engine.seed(std::random_device()()); | |
//create random number range definition (distribution) | |
std::uniform_int_distribution<std::mt19937_64::result_type> randDistro(min, max); | |
return randDistro(engine); | |
} | |
int main() | |
{ | |
//print 10 random numbers | |
for (int index = 1; index < 11; ++index) | |
{ | |
std::cout << "Num " << index << ":\t\t" << genRandRange(0, 5) << std::endl; | |
} | |
std::cin.get(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment