Created
January 14, 2019 02:03
-
-
Save flxxyz/12b34708f253df93ad31ecbe817b9dff to your computer and use it in GitHub Desktop.
简单中奖概率
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $odds = 90; //概率 | |
| $success = 0; | |
| $fail = 0; | |
| $i = 0; | |
| while ($i < 100) { | |
| $rnd = mt_rand(0, 99); | |
| if ($rnd < $odds) { | |
| $success++; | |
| } else { | |
| $fail++; | |
| } | |
| $i++; | |
| } | |
| var_dump("中奖次数=" . $success . ", 没中次数=" . $fail); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment