//快速排序
#include <iostream>
int Paritition(int A[], int low, int high) {
int pivot = A[low];
while (low < high) {
while (low < high && A[high] >= pivot) {
--high;
}
A[low] = A[high];
while (low < high && A[low] <= pivot) {
++low;
}
A[high] = A[low];
}
A[low] = pivot;
return low;
}
void QuickSort(int A[], int low, int high)
{
if (low < high) {
int pivot = Paritition(A, low, high);
QuickSort(A, low, pivot - 1);
QuickSort(A, pivot + 1, high);
}
}
int main() {
int arr[] = {61, 17, 29, 22, 34, 60, 72, 21, 50, 1, 62};
int len = (int)sizeof(arr) / sizeof(*arr);
QuickSort(arr, 0, len - 1);
for (int i = 0; i < len; i++)
std::cout << arr[i] << ' ';
std::cout << std::endl;
return 0;
}