//输入数字按回车进入对应的排序方法 public static void SelectASort() { string i = Console.ReadLine().Trim(); switch (i) { case "1": { Console.WriteLine("<*******冒泡排序法*******>"); int[] numbers = SortUtil.Read(); int[] bubblenumbers = BubbleSort.sort(numbers); SortUtil.Write(bubblenumbers); break; } case "2": { Console.WriteLine("<*******插入排序法*******>"); int[] numbers = SortUtil.Read(); int[] insertnumbers = InsertSort.sort(numbers); SortUtil.Write(insertnumbers); break; } case "3": { Console.WriteLine("<*******希尔排序法*******>"); int[] numbers = SortUtil.Read(); int[] shellnumbers = ShellSort.sort(numbers); SortUtil.Write(shellnumbers); break; } case "4": { Console.WriteLine("<*******简单排序法*******>"); int[] numbers = SortUtil.Read(); int[] simplenumbers = SimpleSort.sort(numbers); SortUtil.Write(simplenumbers); break; } case "5": { Console.WriteLine("<*******归并排序法*******>"); int[] numbers = SortUtil.Read(); int[] mergesort = MergeSort.sort(numbers); SortUtil.Write(mergesort); break; } } }
static void Main(string[] args) { double[] d = { 2, 3, 1, 9, 8, 4, 10 }; List <double> listd = new List <double>(); foreach (double j in d) { listd.Add(j); } sortMethod sortTest = new InsertSort(); sortTest.sort(ref listd); foreach (double num in listd) { Console.WriteLine(num); } Console.ReadKey(); }