3D 摇奖机/ConsoleApp1/Program.cs
(开头部分) 8KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
public enum Prize
{
No_Prize,
First_Prize,//中三个数字,且顺序一致
Second_Prize,//中三个数字,顺序不一致
Third_Prize//中两个数字
}
public struct Lottery
{
public int[] Nums;
public Prize Prize;
}
class Program
{
public static void ShowLotteryByPrize(Lottery[] lottery, int count, Prize prize)
{
for (int i = 0; i < count; i++)
{
if (lottery[i].Prize == prize)
Console.WriteLine("{0},{1},{2}", lottery[i].Nums[0], lottery[i].Nums[1], lottery[i].Nums[2]);
}
}
public static int GetSameNumsCount(int[] lottery, int[] lucyNums)
{
//将中奖号码进行升序排列
Array.Sort(lucyNums);
//为了避免对投注号码顺序的影响,将投注号码进行拷贝至新数组
//创建新的数组用于存储投注号码
int[] lotteryNums = new int[3];
//将投注号码拷贝至新数组中
Array.Copy(lottery, lotteryNums, 3);
//对新数组中的号码进行升序排列
Array.Sort(lotteryNums);
//将投注号码转换为字符串
string str = string.Concat(lotteryNums);
int startIndex = 0;
int sameCount = 0;//用于存储相同数字的个数
//逐一判断中奖号码的每一个数字,在投注号码字符串中是否存在
for (int i = 0; i < 3; i++)
{
int result = str.IndexOf(lucyNums[i].ToString(), startIndex);
if (result != -1)
{
sameCount++;
startIndex = result + 1;
}
}
return sameCount;
}
public static Prize GetPrize(int[] lottery, int[] lucyNums)
{
后面还有 147 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。