A simple two color ball lottery generator

First of all, introduce the rules of two color ball lottery: 1, Way of betting 1. Standard bet Select 6 numbers from the...

First of all, introduce the rules of two color ball lottery:
1, Way of betting
1. Standard bet
Select 6 numbers from the red ball number and 1 number from the blue ball number as a note. The red ball number can be up to 20 numbers, and the blue ball number can be up to all. The maximum bonus of a single note can reach 10 million yuan.

2. Dare to hold back
Among the 33 red ball numbers, 1-5 numbers are selected as the courage code of each note, and other different red ball numbers are added as the drag code for betting. Blue ball has no courage code or drag code. The maximum bonus of a single note can reach 10 million yuan.

3. Single upload
Upload the fixed format single number to the system for betting. This betting method is very convenient for the unified betting of the single number filtered out by the filtering software.
2, Award setting and winning
Prize list:
Prize level winning description single note bonus (the number in front represents the number of red balls, and the number behind represents the number of basketball)
6 + 1 in the first prize (5-4 in red ball and basketball)
6 + 0 in the second prize (six red balls second prize)
Third prize 5 + 1 (five red balls, one basketball third prize)
Fourth prize, 5 + 0, 4 + 1 (5 in red ball and basketball - fourth prize)
Fifth prize 4 + 0, 3 + 1 (red ball and basketball 4-fifth prize)
Sixth prize 2 + 1, 1 + 1, 0 + 1 (middle one basketball sixth prize)

C# implementation:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace caipiaoshengchengqi { class Program { private static int[] BuyTicket() { //Top 6 red balls int[] ticket = new int[7]; for (int i = 0; i < 6;) { Console.WriteLine("Please input number 1.Number of balls:", i + 1); int redNumber = int.Parse(Console.ReadLine()); if (redNumber < 1 || redNumber > 33) Console.WriteLine("Purchase number out of range"); else if (Array.IndexOf(ticket, redNumber) >= 0) Console.WriteLine("Number already exists"); else ticket[i++] = redNumber; } //Basketball 7 while (true) { Console.WriteLine("Please enter the basketball number"); int blueNumber = int.Parse(Console.ReadLine()); if (blueNumber >= 1 && blueNumber <= 16) { ticket[6] = blueNumber; break; } else Console.WriteLine("Number out of range"); } return ticket; } static Random random = new Random(); private static int[] CreatRandomTicket() { int[] ticket = new int[7]; for(int i=0;i<6;) { int redNumber = random.Next(1, 33); if(Array.IndexOf(ticket,redNumber)<0) { ticket[i++] = redNumber; } } ticket[6] = random.Next(1, 16); Array.Sort(ticket, 0, 6); return ticket; } private static int ticketEqual(int[] myTicket, int[] randomTicket) { //Calculate the number of purchased basketball and the number of randomly generated basketball int blueCount = myTicket[6] == randomTicket[6] ? 1 : 0; int redCount = 0; for (int i = 0; i < 6; i++) if (Array.IndexOf(randomTicket, myTicket[i], 0, 6) >= 0) redCount++; int level; if (blueCount + redCount == 7) level = 1; else if (redCount == 6) level = 2; else if (blueCount + redCount == 6) level = 3; else if (blueCount + redCount == 5) level = 4; else if (blueCount + redCount == 4) level = 5; else if (blueCount == 1) level = 6; else level = 0; return level; } private static void Main() { int level; int count = 0; int[] myTicket = BuyTicket(); do { count++; int[] randomTicket = CreatRandomTicket(); level = ticketEqual(myTicket, randomTicket); if (level != 0) Console.WriteLine("Congratulations,First prize, cumulative consumption:", level, count); } while (level != 1);//If you don't win the first prize, you'll keep cycling - you can change it according to your own needs } } }
ZJ.WANG Published 7 original articles, won praise 12, visited 270 Private letter follow

9 February 2020, 02:22 | Views: 2613

Add new comment

For adding a comment, please log in
or create account

0 comments