双色球生成器
protected void Button2_Click(object sender, EventArgs e)
{
Random blueRandom=new Random();
Label2.Text = "<span style='color: red'>" + RandSetNubString(6) + "</span>" + ":<span style='color: blue'>" + blueRandom.Next(1, 17).ToString() + "</span>";
}
string RandSetNubString(int N)
{
string strchar = "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33";
string[] sslist = strchar.Split(',');
string str = "";
int temp = -1;
Random random = new Random();
int[] selected=new int[N];
for (int i = 1; i <N+1; i++)
{
if (temp != -1)
{
random = new Random(i * temp * unchecked((int)DateTime.Now.Ticks));
}
int x = random.Next(1,34);
bool isselect = false;
if (selected.Length > 0)
{
for (int j = 0; j < selected.Length; j++)
{
if (selected[j] == x)
{
isselect = true;
}
}
}
if (temp != -1 && temp == x || isselect==true)
{
return RandSetNubString(N);
}
temp = x;
selected.SetValue(x, selected.Length - 1);
str += sslist[x]+" ";
}
return str;
}