Random ro = new Random(100);

解决方案 »

  1.   

    <p>写的太牛<font color=#ff1493 size=5 face=黑体><strong><em><u><strike>逼了,狂</strike></u></em></strong></font>顶啊</p>  
      

  2.   

    eret
      

  3.   

    sdfsdg
      

  4.   

            static void Main(string[] args)
            {
                ArrayList AList = new ArrayList();//定义可变长数组
                Random rd = new Random();
                int num;//将每次产生的随机数赋给此变量
                bool _bool = true;//判断是否有重复,初始时,数组中没有元素,不需要判断,固赋初值为True
                //产生8个不同的随机数
                while (AList.Count < 8)
                {
                    num = rd.Next(0, 9);
                    for (int i = 0; i < AList.Count; i++)
                    {
                        //如果重复,跳出此循环,重新产生随机数
                        if (num == Convert.ToInt32(AList[i]))
                        {
                            _bool = false;
                            break;
                        }                    //如果与数组中该项不同,则为True
                        else
                        {
                            _bool = true;
                        }
                    }
                    //上面循环后,如果_bool仍为True,则说明此次产生的随机数在数组中无重复,则将此随机数赋给数组
                    if (_bool == true)
                    {
                        AList.Add(num.ToString());
                    }
                }            for (int i = 0; i < AList.Count; i++)
                {
                    Console.WriteLine(AList[i]);
                }
                Console.ReadLine();
            }
      

  5.   


    ArrayList arraylist=new ArrayList();
    Random rand=new Random();
    int array1=rand.next(1,10)
    arraylist.Add(array1);
    while(arraylist.Count<9)
    {
    int tamp=rand.next(1,10);
    if(arraylist.Contains(temp))
    arraylist.Add(temp);
    }
    然后在把arraylist的值拷贝到你的目标数组里头就可以了
      

  6.   

    Random ro = new Random(time);