コード例 #1
0
        static void Main()
        {
            int[] myArray = GetArray();
            int   step    = 0; //этап сортировки

            DisplayArray.ListCurrentlyArray(ref myArray, step);
            OrderArray(ref myArray, step, 0, myArray.Length - 1);
            Console.ReadKey();
        }
コード例 #2
0
        static void OrderArray(ref int[] array, int step, int leftIndex, int rightIndex)
        {
            if (leftIndex > rightIndex)
            {
                return;
            }
            step++;
            int  begin      = leftIndex;
            int  end        = rightIndex;
            int  pivotIndex = 0;
            bool rebuilding = false;

            while (!GetPivot(ref array, ref begin, ref end))
            {
                pivotIndex = end;
                DisplayArray.ListCurrentlyArray(ref array, step, pivotIndex);
                rebuilding = true;
            }
            if (rebuilding)
            {
                OrderArray(ref array, step, leftIndex, pivotIndex - 1);
                OrderArray(ref array, step, pivotIndex + 1, rightIndex);
            }
        }