/// <summary>
 /// 产生符合指定概率的离散分布的随机数组。
 /// </summary>
 /// <param name="n">随机数组的大小。</param>
 /// <param name="probabilities">各取值的概率数组。</param>
 /// <returns>符合指定概率的离散分布的随机数组。</returns>
 public static double[] GetDiscretDistributionArray(int n, double[] probabilities)
 {
     double[] array = new double[n];
     for (int i = 0; i < n; i++)
     {
         array[i] = SortUtil.Discrete(probabilities);
     }
     return(array);
 }
 /// <summary>
 /// 产生符合泊松分布的随机数组。
 /// </summary>
 /// <param name="n">随机数组的大小。</param>
 /// <returns>符合泊松分布的数组。</returns>
 public static double[] GetPossionDistributionArray(int n)
 {
     double[] array = new double[n];
     for (int i = 0; i < n; i++)
     {
         array[i] = SortUtil.Poission(20);
     }
     return(array);
 }
 /// <summary>
 /// 产生符合几何分布的随机数组。
 /// </summary>
 /// <param name="n">随机数组的大小。</param>
 /// <param name="p">几何分布的概率。</param>
 /// <returns>符合几何分布的随机数组。</returns>
 public static double[] GetGeometricDistributionArray(int n, double p)
 {
     double[] array = new double[n];
     for (int i = 0; i < n; i++)
     {
         array[i] = SortUtil.Geometry(p);
     }
     return(array);
 }
 /// <summary>
 /// 获取符合标准正态分布的 double 数组。
 /// </summary>
 /// <param name="n">数组大小。</param>
 /// <returns>符合标准正态分布的 double 数组。</returns>
 public static double[] GetNormalDistributionArray(int n)
 {
     double[] array = new double[n];
     for (int i = 0; i < n; i++)
     {
         array[i] = SortUtil.Normal(0, 1);
     }
     return(array);
 }
Ejemplo n.º 5
0
 public static void Main(string[] args)
 {
     //int[] numbers=SortUtil.Read();
     ////int[] bubblenumbers=BubbleSort.sort(numbers);
     ////int[] insertnumbers = InsertSort.sort(numbers);
     ////int[] shellnumbers = ShellSort.sort(numbers);
     ////int[] simplenumbers = SimpleSort.sort(numbers);
     //int[] merge = MergeSort.Sort(numbers);
     //SortUtil.Write(merge);
     ////SortUtil.Write(bubblenumbers);
     ////SortUtil.Write(simplenumbers);
     Console.WriteLine("按1,2,3,4,5分别选择冒泡,插入,希尔,简单,归并排序法");
     while (true)
     {
         SortUtil.SelectASort();
     }
 }