Advertisement
Benjamin-Franklin

Untitled

Nov 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <random>  
  2. #include <iostream>
  3.  
  4.  
  5. using namespace std;  
  6.  
  7. int main()  
  8. {  
  9.     random_device rd;   // non-deterministic generator  
  10.     mt19937 gen(rd());  // to seed mersenne twister.  
  11.     uniform_int_distribution<> dist(1,6); // distribute results between 1 and 6 inclusive.  
  12.  
  13.     for (int i = 0; i < 5; ++i) {  
  14.         cout << dist(gen) << " "; // pass the generator to the distribution.  
  15.     }  
  16.     cout << endl;  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement