时间:2021-01-01 14:37:11 | 栏目:.NET代码 | 点击:次
废话不多说,直接给大家贴代码,我我就是这么狠。。。
关键代码如下所示:
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();