#include <stdio.h>
#include <stdlib.h>
#define MAXZISE 100
#define ElemType int
int Partition(ElemType A[], int low, int high)
{
ElemType 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(ElemType A[], int low, int high)
{
if (low < high) {
int pivotpos = Partition(A, low, high);
QuickSort(A, low, pivotpos - 1);
QuickSort(A, pivotpos + 1, high);
}
}
int main()
{
ElemType A[MAXZISE];
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &A[i]);
QuickSort(A, 0, n - 1);
for (int i = 0; i < n; i++)
printf("%d ", A[i]);
return 0;
}
05-16
2142
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-22
501
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)