This article mainly introduces to Xiangxu the ASP.NET code that can easily realize red envelope grabbing on WeChat. It has a certain reference value. Interested friends can refer to it.
Everyone in the group is playing Grabbing red envelopes, sending them out again, grabbing them again after sending them out, is simply boring. Programmers are interested in how to implement it. Here I briefly talk about the implementation ideas, and attach the dome. The code is a bit low, but fortunately it is implemented. The specific content is as follows
Text
##100 yuan and 30 red envelopes
50 yuan and 13 red envelopes
10 red envelopes per block
2. Each red envelope must have money
3. Try to make it evenly distributed, otherwise it will be meaningless to grab the red envelopes
Implementation ideas1. First, determine the minimum unit, here it is accurate to the minute. I use int type for calculation here, and the results are all int type
2. The data is even, here 1
4. Disrupt the order. Careful gardeners may find that red envelopes are in order. We must simply write a function to disrupt it.
demo
///?<summary> ?///?搶紅包 ?///?</summary> ?///?<param> ?///?<param> ?///?<returns></returns> ?public?List<int>?qhb(int?money,?int?num) ?{ ??int?min?=?1; ??int?pjs?=?money?/?num; ??List<int>?list?=?new?List<int>(); ??Random?rnd?=?new?Random(); ??for?(int?i?=?0;?i?<pre class="brush:php;toolbar:false">///?<summary> ?///?余數(shù)處理 ?///?</summary> ?///?<param> ?///?<param> ?///?<returns></returns> ?public?List<int>?checklist(int?money,?int?pjs,?List<int>?list) ?{ ??if?(money?!=?0) ??{ ??if?(money?>?0) ??{ ???List<int>?list_order?=?maopao(list); ???//給最小 ???if?(money?/?pjs?==?0) ???{??? ???list_order[0]?+=?money; ???} ???else ???{ ???for?(int?i?=?0;?i??list_order?=?maopao(list,"desc"); ???//給最大 ???if?(money?/?pjs?==?0) ???{ ???list_order[0]?+=?money; ???} ???else ???{ ???for?(int?i?=?0;?i?<pre class="brush:php;toolbar:false">?///?<summary> ??///?冒泡排序 ??///?</summary> ??///?<param> ??///?<param> ??///?<returns></returns> ??public?List<int>?maopao(List<int>?list,string?order?=?"asc") ??{ ??if?(order?!=?"asc") ??{ ???for?(int?i?=?0;?i??list[j]) ???{ ????int?temp?=?list[j]; ????list[j]?=?list[j?+?1]; ????list[j?+?1]?=?temp; ? ????} ???} ???} ??} ??else? ??{ ???for?(int?i?=?0;?i?<pre class="brush:php;toolbar:false">///?<summary> ?///?打亂順序 ??///?</summary> ??///?<param> ??///?<returns></returns> ?public?List<int>?suiji(List<int>?list)? ??{ ??Random?rnd?=?new?Random(); ??for?(int?i?=?0;?i?</int></int>
The above is the detailed content of ASP.NET code easily implements WeChat grabbing red envelopes. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
