Skip to content

Instantly share code, notes, and snippets.

@alchem0x2A
Created April 17, 2018 16:23
Show Gist options
  • Save alchem0x2A/5982cc66273d7a46753315b7f75cb57b to your computer and use it in GitHub Desktop.
Save alchem0x2A/5982cc66273d7a46753315b7f75cb57b to your computer and use it in GitHub Desktop.
[C++] mt19937 snippet
#include <random>
#include <iostream>
int main()
{
std::random_device device;
/* Or use any number replace the device() */
std::mt19937 generator(device());
std::uniform_int_distribution<int> distribution(1,6);
/* generate ten random numbers in [1,6] */
for (size_t i = 0; i < 10; ++i)
{
std::cout << distribution(generator) << ' ';
}
std::cout << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment