Skip to content

Instantly share code, notes, and snippets.

@MannyGozzi
Created July 5, 2018 21:31
Show Gist options
  • Save MannyGozzi/2cc453717b00a7555404acafee600e4a to your computer and use it in GitHub Desktop.
Save MannyGozzi/2cc453717b00a7555404acafee600e4a to your computer and use it in GitHub Desktop.
#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