Advertisement
cd62131

MT rand

Mar 6th, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <chrono>
  2. #include <iostream>
  3. #include <random>
  4. #include <vector>
  5. using namespace std;
  6. int main() {
  7.   unsigned seed = chrono::system_clock::now().time_since_epoch().count();
  8.   mt19937_64 generator(seed);
  9.   uniform_int_distribution<int> dist(1, 500);
  10.   vector<int> v;
  11.   for (int i = 0; i < 10; i++) v.push_back(dist(generator));
  12.   for (auto& e: v) cout << e << ' '; cout << endl;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement