#include #include using namespace std;

int Partition(vector &a,int left,int right){ int pivot = a[left]; while(left < right){ while(a[right] >= pivot && left < right) right--; a[left] = a[right]; while(a[left] <= pivot && left < right) left++; a[right] = a[left]; } a[left] = pivot; return left; }

void QuickSort(vector &a, int left, int right){ //快速排序 if(left < right){ int pivotpos = Partition(a, left, right); QuickSort(a, left, pivotpos); QuickSort(a, pivotpos + 1, right); } } int main(){ int num; scanf("%d", &num); vector a(num); for(int i = 0; i < num; i++){ cin >> a[i]; } int right = a.size() - 1, left = 0; QuickSort(a, left, right); for(int i = 0; i < a.size(); i++) cout<< a[i] << " "; }