Guest User

Untitled

a guest
Aug 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. //c++11
  2. #include <random>
  3.  
  4. int get_random_int(int max, int min=0)
  5. {
  6. std::random_device rd;
  7. // if range is wrong,return min-1
  8. if ((max-min)<=1)
  9. return min-1;
  10.  
  11. int num = min+rd()%(max-min-1);
  12. return num;
  13. }
Add Comment
Please, Sign In to add comment