How to generate a prize based on the prize's winning probability value (0-10000) in php?
How to implement the algorithm? Among 10 prizes
認(rèn)證高級PHP講師
Every station understands what you mean, but the easier way to draw immediately is:
1.從0到100隨即生成一個整數(shù)
2.設(shè)置中獎范圍 比如10%的中獎率 那么1到10是中獎數(shù)字
3.然后根據(jù)抽中后的數(shù)字判斷是幾等獎
If you feel it is not safe, you can also increase the range, such as 0 to 10,000, and then set the winning range, etc.