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> /// 余数处理 /// </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

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

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

Undress AI Tool
Undress images for free

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

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor
