fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <random>
  5.  
  6.  
  7. int main()
  8. {
  9. std::random_device rd;
  10. std::mt19937 rng(rd());
  11. std::uniform_int_distribution<> dist(1,20);
  12.  
  13. // populatle vector with random number of random numbers
  14. std::vector<int> data;
  15. std::generate_n(std::back_inserter(data), dist(rng), [&](){ return dist(rng);});
  16.  
  17. for (auto x : data)
  18. std::cout << x << '\n';
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
7
12
19
16
9
4
19
12
2
18
1
13
11
19
19
9
20
7