ASP. NET code easily achieves red packet snatching on WeChat

Source: Internet
Author: User
This article mainly Introduces ASP that easily achieves red packet snatching. NET code, has a certain reference value, interested friends can refer to this article for everyone to introduce easily achieve the ASP of red packet snatching. NET code, has a certain reference value, interested friends can refer

The group is playing with snatching red packets, snatching and sending them again, which is boring. programmers are interested in how to implement it. here we will briefly talk about the implementation ideas, attach dome, and the code is a bit low, fortunately, it is implemented. the specific content is as follows:

Body

100 yuan and 30 red packets

4. disrupt the order. careful garden friends may find that red packets are ordered. we must simply write a function to disrupt it.

Demo

////// Grab a red envelope ////////////
 Public List
 
  
Qhb (int money, int num) {int min = 1; int pjs = money/num; List
  
   
List = new List
   
    
(); Random rnd = new Random (); for (int I = 0; I <num; I ++) {int max = (money/(num-I )) * 2; int s = rnd. next (min, max); s = checkmoney (s, min, max); list. add (s); money-= s;} // the previous data is reasonable, and the end must be more than or equal to list = checklist (money, pjs, list); return list ;}
   
  
 
////// Remainder processing ////////////
 Public List
 
  
Checklist (int money, int pjs, List
  
   
List) {if (money! = 0) {if (money> 0) {List
   
    
List_order = maopao (list); // minimum if (money/pjs = 0) {list_order [0] + = money;} else {for (int I = 0; I <money/pjs + 1; I ++) {if (I = money/pjs) {list_order [I] + = (money-(money/pjs) * pjs);} else {list_order [I] + = pjs ;}}return list_order;} else {List
    
     
List_order = maopao (list, "desc"); // returns the maximum if (money/pjs = 0) {list_order [0] + = money ;} else {for (int I = 0; I <-(money/pjs) + 1; I ++) {if (I =-(money/pjs )) {list_order [I] + = (money-(money/pjs) * pjs);} else {list_order [I]-= pjs ;}} return list_order ;}} return list ;}
    
   
  
 
////// Bubble sort ////////////
 Public List
 
  
Maopao (List
  
   
List, string order = "asc") {if (order! = "Asc") {for (int I = 0; I <list. count; I ++) {for (int j = 0; j <list. count-I-1; j ++) {if (list [j + 1]> list [j]) {int temp = list [j]; list [j] = list [j + 1]; list [j + 1] = temp ;}}} else {for (int I = 0; I <list. count; I ++) {for (int j = 0; j <list. count-i-1; j ++) {if (list [j + 1] <list [j]) {int temp = list [j]; list [j] = list [j + 1]; list [j + 1] = temp ;}}} return list ;}
  
 
////// Disrupt the order /////////
 Public List
 
  
Suiji (List
  
   
List) {Random rnd = new Random (); for (int I = 0; I <list. count; I ++) {int temp = list [I]; int j = rnd. next (0, list. count-1); list [I] = list [j]; list [j] = temp;} return list ;}
  
 

The above is the detailed content of the ASP. NET code that easily achieves red packet snatching. For more information, see other articles on php Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.