#include<iostream>
using namespace std;
void quicksort(int *list, int s, int t) {
if(s < t) {
int i = s, j = t;
int pivot = list[i]; //枢轴元素
while(i < j) {
//从右左扫描
while(i < j && list[j] >= pivot) {
j--;
}
if(i < j) {
list[i] = list[j];
i++;
}
//从左往右扫描
while(i < j && list[i] <= pivot) {
i++;
}
if(i < j) {
list[j] = list[i];
j--;
}
}
list[i] = pivot;
quicksort(list, s, i-1);
quicksort(list, i+1, t);
}
}
int main() {
int list[10] = {7,3,5,2,1,0,9,2,4,6};
quicksort(list, 0, 9);
for(int i = 0; i < 10; i++){
cout <<list[i] <<" ";
}
return 0;
}