当前位置:网站首页>PHP wechat red packet grabbing algorithm
PHP wechat red packet grabbing algorithm
2022-07-02 22:28:00 【Game programming】
php Wechat red packet algorithm
function qiangHongbao() { $total=10;// Total $num=8;// Divide into 8 Red envelopes , Support 8 People receive at random $min=0.01;// Everyone can at least receive 0.01 element for ($i=1;$i<$num;$i++) { $safe_total=($total-($num-$i)*$min)/($num-$i);// Random safety upper limit $money=mt_rand($min*100,$safe_total*100)/100; $total=$total-$money; echo ' The first '.$i.' Red envelopes :'.$money.' element , balance :'.$total.' element <br/>'; } echo ' The first '.$num.' Red envelopes :'.$total.' element , balance :0 element '; }// Output results // The first 1 Red envelopes :0.08 element , balance :9.92 element // The first 2 Red envelopes :0.82 element , balance :9.1 element // The first 3 Red envelopes :1.4 element , balance :7.7 element // The first 4 Red envelopes :0.87 element , balance :6.83 element // The first 5 Red envelopes :1.07 element , balance :5.76 element // The first 6 Red envelopes :2.47 element , balance :3.29 element // The first 7 Red envelopes :1.01 element , balance :2.28 element // The first 8 Red envelopes :2.28 element , balance :0 element
author :. Week week
Game programming , A game development favorite ~
If the picture is not displayed for a long time , Please use Chrome Kernel browser .
边栏推荐
- Servicemesh mainly solves three pain points
- [shutter] shutter resource file use (import resource pictures | use image resources)
- Reading experience of just because
- The book "new programmer 002" is officially on the market! From "new database era" to "software defined car"
- 情感计算与理解研究发展概述
- TinyMCE visual editor adds Baidu map plug-in
- Necessary browser plug-ins for network security engineers
- [shutter] shutter gesture interaction (small ball following the movement of fingers)
- The difference between include < > and include ""
- "New programmer 003" was officially launched, and the cloud native and digital practical experience of 30+ companies such as Huawei and Alibaba
猜你喜欢
GEE:(二)对影像进行重采样
《Just because》阅读感受
20220702-程序员如何构建知识体系?
Five message formats of OSPF
New feature of go1.18: introduce new netip Network Library
《ActBERT》百度&悉尼科技大学提出ActBERT,学习全局局部视频文本表示,在五个视频-文本任务中有效!
[shutter] shutter application theme (themedata | dynamic modification theme)
[shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)
An overview of the development of affective computing and understanding research
The book "new programmer 002" is officially on the market! From "new database era" to "software defined car"
随机推荐
Pointer array parameter passing, pointer parameter passing
The source code of the daily book analyzes the design idea of Flink and solves the problems in Flink
Destroy in beforedestroy invalid value in localstorage
phpcms实现订单直接支付宝支付功能
Learn computer knowledge from scratch
PIP audit: a powerful security vulnerability scanning tool
An overview of the development of affective computing and understanding research
C语言,实现三子棋小游戏
Gee: (II) resampling the image
App page sharing password rails implementation
LxC terminal login method
[QT] Q multithreaded development - Analysis of multithreaded application examples (Mandelbrot)
Les trois principaux points de douleur traités par servicemesh
tinymce可视化编辑器增加百度地图插件
Perceptron model and Application
Tencent three sides: in the process of writing files, the process crashes, and will the file data be lost?
Attack and defense world PWN question: Echo
服务可见可观测性
情感计算与理解研究发展概述
Error in PIP installation WHL file: error: is not a supported wheel on this platform