#include <bits/stdc++.h>
using namespace std;

int Partition(int arr[], int i, int j) {
int temp = arr[i];
while(i != j) {
while( i < j && temp < arr[j])
j--;
arr[i] = arr[j];
while( i < j && temp > arr[i])
i++;
arr[j] = arr[i];
}
arr[i] = temp;
return i;
}

int QuickSort(int arr[], int s, int t) {
if(s < t) {
int i = Partition(arr, s, t);
QuickSort(arr, s, i-1);
QuickSort(arr, i + 1, t);
}

}

void disp(int arr[], int n) {
for(int i = 0; i < n; i++)
cout << " "<< arr[i];
cout << endl;
}

int main() {
int a[] = {2, 5, 1, 7, 10, 6, 9, 4, 3, 8};
int n = sizeof(a) / sizeof(a[0]);
cout << "排序前:";
disp(a,n);
QuickSort(a,0,n-1);
cout << "排序后:";
disp(a,n);

return 0;
}