Пример #1
0
        static void SortInts()
        {
            Console.WriteLine("对整型数组排序:");
            int[] intArray = { 12, 2, 34, 15, 23, 11, 6, 9, 11 };
            QuickSorter<int> intSorter = new QuickSorter<int>(intArray, CompareInt);

            Console.WriteLine("排序之前的整型数组:");
            foreach ( int num in intArray )
            {
                Console.Write(num + "  ");
            }
            Console.WriteLine("\n排序之后的整型数组:");
            foreach ( int num in intSorter.ArrayAfterSort() )
            {
                Console.Write(num + "  ");
            }
        }
Пример #2
0
        static void SortStrings()
        {
            Console.WriteLine("对字符串数组排序:");
            string[] strArray = { "zpasd", "qwe", "wer", "fgdg", "ertw", "qrtre" };
            QuickSorter<string> strSorter = new QuickSorter<string>(strArray, CompareString);

            Console.WriteLine("排序之前的字符串数组:");
            foreach ( string str in strArray )
            {
                Console.Write(str + "  ");
            }
            Console.WriteLine("\n排序之后的字符串数组:");
            foreach ( string str in strSorter.ArrayAfterSort() )
            {
                Console.Write(str + "  ");
            }
        }