Created
April 17, 2018 16:23
-
-
Save alchem0x2A/5982cc66273d7a46753315b7f75cb57b to your computer and use it in GitHub Desktop.
[C++] mt19937 snippet
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 <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