程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> C#雙色球——簡單抽取中獎號碼,

C#雙色球——簡單抽取中獎號碼,

編輯:C#入門知識

C#雙色球——簡單抽取中獎號碼,


            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();

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved