using System;
class A
{
static void Main()
{
Random free=new Random();
int a=free.Next(1,15);
int change;
int[] number={16,2,13,4,18,20,7,12,9,17,11,8,3,14,15,1,10,5,19,6};
for(int j=0;j<100;j++)
//混排
{
if(a<=4)
{
a=free.Next(0,3);
}
if(a>=5 && a<=8)
{
a=free.Next(4,7);
}
if(a>9 && a<13)
{
a=free.Next(8,11);
}
if(a>=14 && a<=18)
{
a=free.Next(12,15);
}
change=number[a];
number[a]=number[a+4];
number[a+4]=change;
a=free.Next(0,18);
}
for(int i=0;i<20;i++)
{
Console.WriteLine("{0}班,在第{1}考场",i+1,number[i]);
}
}
}
终于自己写出来了.