1#include <iostream>
2#define MAX 100
3using namespace std;
4int Partition(int A[], int START, int END) {
5 int PIVOT = A[END], I = START, J, TEMP;
6 for (J = START; J <= END - 1; J++)
7 if (A[J] < PIVOT) {
8 TEMP = A[I];
9 A[I] = A[J];
10 A[J] = TEMP;
11 I++;
12 }
13 TEMP = A[I];
14 A[I] = A[END];
15 A[END] = TEMP;
16 return I;
17}
18void QuickSort(int A[], int START, int END) {
19 if (START < END) {
20 int PIVOT = Partition(A, START, END);
21 QuickSort(A, START, PIVOT - 1);
22 QuickSort(A, PIVOT + 1, END);
23 }
24}
25void main() {
26 int A[MAX], n, I, J, TEMP;
27 cin >> n;
28 for (I = 0; I < n; I++)
29 cin >> A[I];
30 QuickSort(A, 0, n - 1);
31 for (I = 0; I < n; I++)
32 cout << A[I] << " ";
33}