fork(6) download
  1. #include <random>
  2. class Engine
  3. {
  4. public:
  5. Engine() :
  6. m_generator(std::random_device()()),
  7. m_distribution(0, 36)
  8. {}
  9.  
  10. int spin() { return m_distribution(m_generator); }
  11. private:
  12. std::mt19937 m_generator;
  13. std::uniform_int_distribution<int> m_distribution;
  14.  
  15. };
  16.  
  17. #include <iostream>
  18.  
  19. int main()
  20. {
  21. Engine eng;
  22.  
  23. for(int i = 0; i < 20; ++i)
  24. std::cout << eng.spin() << '\n';
  25. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
31
0
7
22
23
0
23
36
5
14
17
36
19
33
17
21
29
26
28
14