class QuickSort ...{ publicstaticvoid QSort(int[] A) ...{ Sort(A, 0, A.Length-1); } privatestaticvoid Sort(int[] A, int p, int r) ...{ if (p<r) ...{ int q; q = Partition(A, p, r); Sort(A, p, q -1); Sort(A, q +1, r); } } // 分解 privatestaticint Partition(int[] A, int p, int r) ...{ int i = p -1; int x = A[r]; for (int j = p; j < r; j++) ...{ if (x > A[j]) ...{ i++; Exchange(ref A[i], ref A[j]); } } Exchange(ref A[i +1], ref A[r]); return i +1; } //交换 privatestaticvoid Exchange(refint a, refint b) ...{ int temp; temp = a; a = b; b = temp; } }