Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

random number generation c++

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 0.27 KB  |  hits: 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. }