fork download
  1. #include <iostream>
  2. #include <random>
  3.  
  4.  
  5. int main() {
  6. std::random_device rd; //Will be used to obtain a seed for the random number engine
  7. std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
  8. std::uniform_int_distribution<> dis(-5, 5);
  9. for( int i = 0; i < 5; ++i ) std::cout << dis(gen) << " ";
  10. std::cout << std::endl;
  11. return 0;
  12. }
Success #stdin #stdout 0s 4500KB
stdin
Standard input is empty
stdout
-1 -5 1 -2 -2