C#双色球——简单抽取中奖号码

时间:2024-09-22 22:04:26

int[] ss = new int[6];
            Random s = new Random();
            Console.WriteLine("双色球随机:");
            for (int i = 0; i < 6; i++)
            {
                bool b = true;
                int a = s.Next(1, 34);
                for (int j = 0; j < i; j++)
                {
                    if (a == ss[j])
                    {
                        b = false;
                        i--;
                    }
                }
                if (b)
                {
                    ss[i] = a;
                }
            }
            Console.Write("红球:\t");
            for (int i = 0; i < 6; i++)
            {
                for (int j = i; j < 5; j++)
                {
                    if (ss[i] > ss[j + 1])
                    {
                        int zhong = ss[i];
                        ss[i] = ss[j + 1];
                        ss[j + 1] = zhong;
                    }
                }
               
                Console.Write(ss[i] + "\t");
            }
             for (int i = 0; i < 7 ; i++)
            {
                int b = s.Next(1, 17);
                if (i == 6)
                {
                    Console.Write("蓝球:" + b + "\t");
                }
                else
                {
                    continue ;
                }
            }
            Console.ReadLine();