快排的模板
#include<cstdio>
const int maxn = 100005;
int arr[maxn]={0};
void quickSort(int *arr,int left,int right){
int i = left,j =right;
int mid = arr[(i+j)/2];
while(i<=j){
while(arr[i]<mid) i++;
while(arr[j]>mid) j--;
if(i<=j){
int tmp;
tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
i++;
j--;
}
}
if(i<right) quickSort(arr,i,right);
if(j>left) quickSort(arr,left,j);
}
int main(){
int n;
scanf("%d",&n);
for(int i =0;i<n;i++){
scanf("%d",&arr[i]);
}
quickSort(arr,0,n-1);
for(int i =0;i<n;i++){
printf(i==0?"%d":" %d",arr[i]);
}
printf("\n");
return 0;
}