static List<int> GenerateNumber1()
{
List<int> result =new List<int>(100);
Random random =new Random();
int temp =0;
while (result.Count <100)
{
temp = random.Next(1, 34);
if (!result.Contains(temp))
{
result.Add(temp);
}
}
return result;
}
static List<int> GenerateNumber2()
{
List<int> container =new List<int>(33);
List<int> result =new List<int>(6);
Random random =new Random();
for (int i =1; i <=33; i++)
{
container.Add(i);
}
int index =0;
int value =0;
for (int i =1; i <=6; i++)
{
index = random.Next(0, container.Count);
value = container[index];
result.Add(value);
container.RemoveAt(index);
}
return result;
}
staticint[] GenerateNumber3()
{
// 用于存放1到33这33个数
int[] container =newint[33];
//用于保存返回结果
int[] result =newint[6];
Random random =new Random();
for (int i =0; i <33; i++)
{
container[i] = i +1;
}
int index =0;
int value =0;
for (int i =0; i <6; i++)
{
//从[1,container.Count + 1)中取一个随机值,保证这个值不会超过container的元素个数
index = random.Next(0, container.Length - i);
//以随机生成的值作为索引取container中的值
value = container[index];
//将随机取得值的放到结果集合中
result[i] = value;
//将刚刚使用到的从容器集合中移到末尾去
container[index] = container[container.Length - i -1];
//将队列对应的值移到队列中
container[container.Length - i -1] = value;
}
return result;
}