Advertisement
Kagalive

basic-random

Oct 1st, 2020
1,489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2. #include <random>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.   //seed
  9.   random_device seed{};
  10.  
  11.   //rnd gen
  12.   mt19937 engine{seed()};
  13.  
  14.   //uniform distribution [1..10]
  15.   uniform_int_distribution<> dis{1, 10};
  16.  
  17.   //generate random number
  18.   int x{ dis(engine) };
  19.  
  20.   //output
  21.   cout << x << "\n";
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement