求用最简洁的代码,计算机运行次数最少,随生成0-9这十个数字?

解决方案 »

  1.   

    奉献一套商业进销存系统 C#2005代码,需要的请下载。总共六卷。文档另分一卷,下载地址http://applemacosx.download.csdn.net/
      

  2.   

    class Program
    {
      static void Main()
      {
        System.Random r = new System.Random();
        int[] a = new int[]{0,1,2,3,4,5,6,7,8,9};
        for (int i = a.Length; i > 1; i--)
        {
          int j = r.Next(i);
          int t = a[i - 1];
          a[i - 1] = a[j];
          a[j] = t;
        }
        
        // 输出结果
        foreach (int x in a) System.Console.WriteLine(x);
      }
    }
      

  3.   

    Sub Main()        Dim List As New List(Of Integer)
            For i As Integer = 0 To 9
                List.Add(i)
            Next        Dim Count As Integer = 0
            Dim Rnd As New Random
            Dim Index As Integer = 0
            For k As Integer = 0 To 9            Count = List.Count - 1
                Index = Rnd.Next(0, Count)
                Console.WriteLine(List(Index))
                List.RemoveAt(Index)        Next        Console.Read()    End Sub
      

  4.   


    - -   给了思路,没给代码就不给分..给LZ一点思考的余地嘛LZ太不厚道了...下次,我也要把代码写出来啦.  每天10分  哦也.