本文控制模拟双色球随机选取球的功能,对这方面有兴趣的朋友,可以看下代码哦。

Code
[http://www.xueit.com]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;//线程命名空间必需引用
using System.Collections;//集全命名空间必需引用
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
static void 双色球()
{
ArrayList redbollbox = new ArrayList();//设置一个装红球箱
ArrayList redboll = new ArrayList();//设置一个装已滚出来的红球箱
ArrayList bluebollbox = new ArrayList();//设置一个装蓝球箱
object blueboll;//出来的蓝球
for (int i = 1; i <= 33; i )//给红球写号
{
redbollbox.Add(i);
}
for (int i = 1; i <= 16; i )//给蓝球写号
{
bluebollbox.Add(i);
}
Console.WriteLine("红球滚动中");
for (int i = 0; i < 6; i )//滚球
{
Thread.Sleep(5000);//滚球等待
int outboll = new Random().Next(0, redbollbox.Count - 1);//随机选球的编号
redboll.Add(redbollbox[outboll]);//出来的球
Console.WriteLine("第{0}个球:{1}", i 1, redboll[i]);//滚出的球号是几
redbollbox.RemoveAt(outboll);//去掉出来的球 redbollbox.TrimToSize();//球箱的球减少
}
Console.WriteLine("蓝球滚动中");
Thread.Sleep(5000);
blueboll = bluebollbox[new Random().Next(0, bluebollbox.Count - 1)];
Console.WriteLine("最后的蓝球是:{0}", blueboll);
redboll.Sort();//红球排序
Console.Write("红球区:");
foreach (object item in redboll)
{
Console.Write("{0} ", item);}
Console.Write(" 蓝球号:{0}
", blueboll);
}
}
精彩图集