Random r = new Random();
int[] a = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
for (int i = 0; i < 10; ++i)
{
int j = r.Next(9);
int t = a[j];
a[j] = a[i];
a[i] = t;
}
for (int i = 0; i < 9; ++i)
Console.Write("{0} ", a[i]);
Console.WriteLine();
}
int[] arrNum=new int[9];
Random ra=new Random();
for(int i=0;i<9;i++)
{
int[i]=ra.Next(9);
}
这样就行了吧!
Random r=new Random();
int[] num=new int[9];
for(int i=0;i
int j = r.Next(9);
if(i==0){
int[i]=j;
}
while(true)
{
int h=0;
for(h=0;h {
if(j=num[h])
{
j = r.Next(9);
break;
}
}
if(h==i)
{
int[i]=j;
break;
}
}
}