-
-
- static List<int> GetRandomArray(int maxNumber,int count)
- {
- List<int> list = new List<int>();
- int[] array=new int[maxNumber];
- for (int i = 0; i < maxNumber; i++)
- array[i] = i + 1;
- Random rnd = new Random();
- for (int j = 0; j < count; j++)
- {
- int index = rnd.Next(j,maxNumber);
- int temp = array[index];
- list.Add(temp);
- array[index] = array[j];
- array[j] = temp;
- }
- return list;
- }
|
请发表评论