fork download
  1. #include <tr1/random>
  2. #include <iostream>
  3.  
  4. std::tr1::mt19937& get_engine() {
  5. static std::tr1::random_device device;
  6. static std::tr1::mt19937 eng = std::tr1::mt19937(device());
  7. return eng;
  8. } //seeds only once, no matter what
  9.  
  10. int main() {
  11. std::tr1::uniform_int<int> unif(0, 255);
  12. int i = unif(get_engine());
  13. std::cout << i << '\n';
  14. }
Runtime error #stdin #stdout 0s 3060KB
stdin
Standard input is empty
stdout
Standard output is empty