C#快速排序代码演示
private static int Partition (int[] list, int i, int j) { int Key = list [i]; while (i < j) { //j to the left scan while (list [j] >= Key && i < j) j--; if(i< j) list [i++] = list [j]; //i to the right scan 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); } }