SHARE
TWEET

random number generation c++

a guest Aug 9th, 2012 13 Never
  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. }
RAW Paste Data
Top