题目:
题解:
// The rand7() API is already defined for you.
// int rand7();
// @return a random integer in the range 1 to 7
int rand10() {
while(true) {
int index = (rand7() - 1) * 7 + rand7();
if(index <= 40) return index % 10 + 1;
}
}