using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace myQuickSort
{
class Program
{
static void Main(string[] args)
{
int[] myArray = new int[] { 45, 36, 18, 53, 72, 13, 12 };
QuickSortFunction1(myArray, 0, myArray.Length - 1);
foreach (int i in myArray)
{
Console.WriteLine(i.ToString());
}
Console.ReadLine();
}
private static int QuickSortFunction0(int [] array,int low ,int high)
{
while (high > low)
{
int keyValue = array[low];
do
{
while (high > low && array[high] >= keyValue)
{
high--;
}
swap(ref array[low], ref array[high]);
while (low < high && array[low] < keyValue)
{
low++;
}
swap(ref array[low], ref array[high]);
}
while (low != high);
}
return low;
}
private static void QuickSortFunction1(int[] array,int low ,int high)
{
if (low >= high)
return;
int keyValueIndex = QuickSortFunction0(array, low, high);
QuickSortFunction1(array, low, keyValueIndex - 1);
QuickSortFunction1(array, keyValueIndex + 1, high);
}
private static void swap( ref int i,ref int j)
{
int temp;
temp = i;
i = j;
j = temp;
}
}
}
07-25
07-25
07-25
07-25