fork download
  1. #include <random>
  2. #include <iostream>
  3.  
  4. typedef std::mt19937 random_eng;
  5. //typedef std::minstd_rand random_eng;
  6.  
  7. int f(int x) {
  8. std::seed_seq sq(&x, &x + 1);
  9. auto rnd = random_eng(sq);
  10. return std::uniform_int_distribution<int>()(rnd);
  11. }
  12.  
  13. int g(int x) {
  14. std::seed_seq sq(&x, &x + 1);
  15. auto rnd = random_eng();
  16. rnd.seed(sq);
  17. return std::uniform_int_distribution<int>()(rnd);
  18. }
  19.  
  20. int main() {
  21. std::cout << f(0) << " " << f(0) << std::endl;
  22. std::cout << g(0) << " " << g(0) << std::endl;
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 3020KB
stdin
Standard input is empty
stdout
1574211392 687539329
2019020746 2019020746