快速排序
#include<stdio.h>
int partition(int a[],int low,int high){
int k = a[low];
while(low<high){
while(low<high && a[high] >= k) high--;
a[low] = a[high];
while(low<high && a[low] <= k) low++;
a[high] = a[low];
}
a[low] = k;
return low;
}
void quickSort(int a[],int low,int high){
if(low < high){
int p = partition(a,low,high);
quickSort(a,low,p-1);
quickSort(a,p+1,high);
}
}
int main(){
int n;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++) scanf("%d",&a[i]);
quickSort(a,0,n-1);
for(int i=0;i<n;i++) printf("%d ",a[i]);
}