当前位置:网站首页>PHP微信抢红包的算法
PHP微信抢红包的算法
2022-07-03 07:41:00 【.周周】
php微信红包算法
function qiangHongbao() {
$total=10;//总额
$num=8;// 分成8个红包,支持8人随机领取
$min=0.01;//每个人最少能收到0.01元
for ($i=1;$i<$num;$i++) {
$safe_total=($total-($num-$i)*$min)/($num-$i);//随机安全上限
$money=mt_rand($min*100,$safe_total*100)/100;
$total=$total-$money;
echo '第'.$i.'个红包:'.$money.' 元,余额:'.$total.' 元 <br/>';
}
echo '第'.$num.'个红包:'.$total.' 元,余额:0 元';
}
// 输出结果
// 第1个红包:0.08 元,余额:9.92 元
// 第2个红包:0.82 元,余额:9.1 元
// 第3个红包:1.4 元,余额:7.7 元
// 第4个红包:0.87 元,余额:6.83 元
// 第5个红包:1.07 元,余额:5.76 元
// 第6个红包:2.47 元,余额:3.29 元
// 第7个红包:1.01 元,余额:2.28 元
// 第8个红包:2.28 元,余额:0 元
边栏推荐
- Structure of golang
- Enter three times and guess a number
- Sent by mqtt client server of vertx
- 华为交换机:配置telnet和ssh、web访问
- Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once
- Go language foundation ----- 19 ----- context usage principle, interface, derived context (the multiplexing of select can be better understood here)
- Lombok -- simplify code
- 技术干货 | AlphaFold/ RoseTTAFold开源复现(2)—AlphaFold流程分析和训练构建
- C2-关于VCF文件合并的几种方法
- PAT甲级 1027 Colors in Mars
猜你喜欢
OSPF experiment
Use of other streams
Common architectures of IO streams
Go language foundation ----- 19 ----- context usage principle, interface, derived context (the multiplexing of select can be better understood here)
技术干货|昇思MindSpore NLP模型迁移之Bert模型—文本匹配任务(二):训练和评估
Custom generic structure
Technical dry goods Shengsi mindspire innovation model EPP mvsnet high-precision and efficient 3D reconstruction
【CoppeliaSim4.3】C#调用 remoteApi控制场景中UR5
Traversal in Lucene
Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire
随机推荐
密西根大学张阳教授受聘中国上海交通大学客座教授(图)
Comparison of advantages and disadvantages between most complete SQL and NoSQL
OSPF experiment
Iterm2设置
GoLang之结构体
Industrial resilience
Rabbit MQ message sending of vertx
Go language foundation ----- 19 ----- context usage principle, interface, derived context (the multiplexing of select can be better understood here)
SQL create temporary table
Pgadmin 4 v6.11 release, PostgreSQL open source graphical management tool
Inverted chain disk storage in Lucene (pfordelta)
Implementation of breadth first in aggregation in ES
Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire
Chapter VI - Containers
Go language foundation ----- 05 ----- structure
Reconnaissance et détection d'images - Notes
Paper learning -- Study on the similarity of water level time series of Xingzi station in Poyang Lake
Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore
Go language foundation ----- 15 ----- reflection
Structure of golang