Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

random number generation c++

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 0.27 KB  |  views: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <random>
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     std::random_device rd;
  7.     std::mt19937 gen(rd());
  8.     std::uniform_int_distribution<> dis(-1, 1);
  9.     for(int n=0; n<10; ++n)
  10.         std::cout << dis(gen) << ' ';
  11.     std::cout << '\n';
  12. }