Guest User

Untitled

a guest
Jul 17th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. // The rand7() API is already defined for you.
  2. // int rand7();
  3. // @return a random integer in the range 1 to 7
  4.  
  5. class Solution {
  6. public:
  7. int rand10() {
  8. int num = 40;
  9. while (num >= 40)
  10. num = 7 * (rand7() - 1) + (rand7() - 1);
  11. return num % 10 + 1;
  12. }
  13. };
Add Comment
Please, Sign In to add comment