static void Main(string[] args)
{
// a是要生成结果的数组
int[] a = new int[100];
int [] b=new int[100];
Random r = new Random();
for (int i = 1; i < 101; i++)
{
b[i - 1] = i;
}
int temp = -1;
for (int i = 100; i > 0; i--)
{
int n = r.Next(1, i);
a[i - 1] = b[n-1];
temp = b[i-1];
b[i-1] = b[n-1];
b[n-1] = temp;
}
for (int i = 0; i < 100;i++ )
{
if (i % 10 != 0)
{
Console.Write(a[i] + "\t");
}
else
Console.WriteLine();
}
Console.ReadKey();
}
{
// a是要生成结果的数组
int[] a = new int[100];
int [] b=new int[100];
Random r = new Random();
for (int i = 1; i < 101; i++)
{
b[i - 1] = i;
}
int temp = -1;
for (int i = 100; i > 0; i--)
{
int n = r.Next(1, i);
a[i - 1] = b[n-1];
temp = b[i-1];
b[i-1] = b[n-1];
b[n-1] = temp;
}
for (int i = 0; i < 100;i++ )
{
if (i % 10 != 0)
{
Console.Write(a[i] + "\t");
}
else
Console.WriteLine();
}
Console.ReadKey();
}