20150506--不重复的随机(备忘)

            Random suiji = new Random();
            int[] shuzu = new int[5];
            for (int i = 0; i < 5; i++)
            {
                shuzu[i] = suiji.Next(1, 6);
                for (int j = 0; j < i; j++)
                {
                    if (shuzu[i] == shuzu[j])
                    {
                        i--;
                        break;
                    }
                }
            }
            foreach (int q in shuzu)
            {
                Console.WriteLine(q);
            }
            Console.ReadLine();

 

posted @ 2015-05-06 17:16  Tirisfal  阅读(123)  评论(0编辑  收藏  举报