将1-1000区间的数分配给数组,要求不能有重复的值

public static void SetArray(int[] arrayint)
        {
            // int[] arrayint = new int[100];
            Random random = new Random();
            for (int i = 1; i <= 1000; i++)
            {
                int index = random.Next(0, 1000);
                if (arrayint[index] == 0)
                    arrayint[index] = i;
                else i--;
            }
            foreach (int i in arrayint)
            {
                Console.Write(i);
                Console.Write("\t");
            }
        }

posted @ 2013-08-25 16:53  爱起早的小D  阅读(201)  评论(0编辑  收藏  举报