Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5ab9690

Browse files
zhangzz2015gitbook-bot
authored andcommitted
GitBook: [greyireland#111] No subject
1 parent 4d8ecb8 commit 5ab9690

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

‎suan-fa-si-wei/sampling-fang-fa.md‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,20 @@
66

77
```cpp
88
// Some cc++
9-
9+
// transfer rand7 to rand10.
10+
class Solution {
11+
public:
12+
int rand10() {
13+
14+
// [1 7] (rand7()-1) * 7 + rand7() -1 [ 0 48] >=40. descard.
15+
int random = 49;
16+
while(random>=40)
17+
{
18+
random = (rand7()-1)*7 + rand7() -1;
19+
}
20+
21+
return random%10+1;
22+
23+
}
24+
};
1025
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /