Random in C++11


SUBMITTED BY: Guest

DATE: Sept. 24, 2014, 4:24 p.m.

FORMAT: C++

SIZE: 291 Bytes

HITS: 576

  1. #include <random>
  2. int main()
  3. {
  4. std::random_device dv;
  5. std::mt19937 gen(dv()); //Create and seed mt19937 engine with random_device
  6. std::uniform_int_distribution<> dist(0, 100);
  7. int t[100];
  8. for(int &i : t)
  9. i = dist(dv);
  10. return 0;
  11. }

comments powered by Disqus