抢红包的原理,该怎么处理

WBOY
Release: 2016-06-13 12:17:32
Original
1516 people have browsed it

抢红包的原理
想用php实现抢红包的功能,谁发的红包越多,抢的也多,不知道要是什么算法合适
------解决思路----------------------
我想到个思路不知道合不合适 (新手莫喷)
建立两个随机数,比如说一个是0-100  随机到多少 给红包 比如说这个数字是1-10对应获得红包 ,你的概率就是10%
另一个随机数 范围0-50 随机获得一个数字 比如也是1-10 对应获得红包 这样概率就是20% 对面;
至于 是第一种还是第二种 就根据数据库中的top10 决定给那种吧
以上只是本人一点想法 经此而已
------解决思路----------------------
你会记录每个人发的红包个数(金额数)
所以你会知道某个人发的红包个数(金额数),占整体红包个数(金额数)的比例
照此比例就可满足 谁发的红包越多,抢的也多 的要求

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!