今天team招人,team里的两位仁兄在地铁上随意想的,看来准备面试的时候不用看太多的题,题都是这么出来的
Random random = new Random();
ArrayList intTempArr = new ArrayList();
int[] intArr = new int[100];
for (int i = 1; i < 101; i++)
{
intTempArr.Add(i);
}
for (int j = 0; j < intArr.Length; j++)
{
if (intTempArr.Count == 0)
return;
int temp = random.Next(intTempArr.Count - 1);
int tempValue = (int)intTempArr[temp];
intArr[j] = tempValue;
intTempArr.RemoveAt(temp);
Console.Write("intArr[" + j + "]=" + tempValue + "\n\r");
}