[求助]随机填充数组及判断重复数据的问题
用1-9之间的数填充长度为9的数组,并且不能有重复数据,该如何做呢?
急 !!在线等
下面是四个数组的例子,按照下面的你做做试试,还是行的话给我写信,我做个发给你 ,邮箱:hyj19851103@163.com
int[] Shu = new int[4] { 0,0,0,0};
for (int i = 1; i <= 4; i++)
{
bool chong=true;
Random randShu = new Random();
int shu=0;
while (chong)
{
shu = randShu.Next(9);
chong = false;
for (int k = 0; k < i-1; k++)
{
if (shu == Shu[k])
{
chong = true;
}
}
}
Shu[i - 1] = shu;
}