如下的资料是关于C#快速排序演示的代码,应该对各位朋友有用处。
private static int Partition (int[] list, int i, int j)
{
int Key = list [i];
while (i < j)
{
while (list [j] >= Key && i < j)
j--;
if(i< j)
list [i++] = list [j];
while (list [i] <= Key && i < j)
i++;
IF (i < j)
list [j--] = list[i];
}
list [i] = Key;
return i;
}
public static void QuickSort (int[] list, int low, int high)
{
if(low < high - 1)
{
int Key = Partition (list, low, high);
QuickSort (list, low, Key - 1);
QuickSort (list, Key + 1, high);
}
}