Skip to content

Instantly share code, notes, and snippets.

@ubaidh
Created January 7, 2019 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ubaidh/30888e2c99acbab45785d7efc941dfcd to your computer and use it in GitHub Desktop.
Save ubaidh/30888e2c99acbab45785d7efc941dfcd to your computer and use it in GitHub Desktop.
<random> function to print random numbers
#include<iostream>
#include<random>
void printrandom(std::default_random_engine e) {
for (int i = 0; i < 10; i++) {
std::cout << e() << " ";
}
std::cout << "\n";
}
int main(int argc, char**agrv) {
std::default_random_engine eng;
std::default_random_engine eng2;
printrandom(eng);
printrandom(eng2); //both produce same numbers
std::cin.get();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment