Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("--------冒泡排序---------");
            int[] Datas1 = { 3, 6, 5, 9, 7, 1, 8, 2, 4 };
            SortingHelper <int> .BubbleSort(Datas1);

            PrintData(Datas1);

            Console.WriteLine("------直接插入排序-------");
            int[] Datas2 = { 5, 4, 45, 69, 23, 52, 109, 33 };
            SortingHelper <int> .StraightInsertSort(Datas2);

            PrintData(Datas2);

            Console.WriteLine("------快速排序-------");
            int[] Datas3 = { 15, 34, 45, 87, 213, 22, 109, 33 };
            SortingHelper <int> .QuickSort(Datas3, 0, Datas3.Length - 1);

            PrintData(Datas3);

            Console.WriteLine("------简单选择排序-------");
            int[] Datas4 = { 55, 34, 5, 87, 23, 22, 19, 38 };
            SortingHelper <int> .SimpleSelectSort(Datas4);

            PrintData(Datas4);

            Console.WriteLine("------堆排序-------");
            int[] Datas5 = { 5, 3, 25, 7, 223, 72, 109, 83 };
            SortingHelper <int> .HeapSort(Datas5);

            PrintData(Datas5);

            Console.WriteLine("------二路归并排序-------");
            int[] Datas6 = { 65, 73, 2, 7, 71, 49, 9, 81 };
            SortingHelper <int> .MergeSort(Datas6, 0, (Datas6.Length - 1));

            PrintData(Datas6);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //var arr = InitializeData(10000);
            //Utility.CodeTimerHelper.Time("插值", 1, () =>
            //{
            //    SortingHelper<int>.StraightInsertSort(arr);
            //});
            //var arr1=InitializeData(100000);
            //Utility.CodeTimerHelper.Time("希尔排序", 1, () =>
            //{
            //    SortingHelper<int>.ShellSort(arr1);
            //});
            //var arr2 = InitializeData(10000);
            //Utility.CodeTimerHelper.Time("冒泡", 1, () =>
            //{
            //    SortingHelper<int>.BubbleSort(arr2);
            //});
            //var arr3 = InitializeData(100000);
            //Utility.CodeTimerHelper.Time("快速排序", 1, () =>
            //{
            //    SortingHelper<int>.QuickSort(arr3,0, arr3.Length - 1);
            //});
            //var arr4 = InitializeData(100000);
            //Utility.CodeTimerHelper.Time("堆排序", 1, () =>
            //{
            //    SortingHelper<int>.HeapSort(arr4);
            //});
            //PrintData(arr3);

            int[] arrTest = { 5, 8, 3, 6, 1, 9, 7, 4, 2 };
            PrintData(arrTest);
            SortingHelper <int> .BubbleSort(arrTest);


            //ConsoleColor currentForeColor = Console.ForegroundColor;
            //Console.ForegroundColor = ConsoleColor.Yellow;
            //Console.WriteLine("Hello World!");
        }