提交时间:2024-08-19 22:45:08
运行 ID: 168115
#include <bits/stdc++.h> using namespace std; int n,a[114514],flag; void quicksort(int a[],int left,int right){ int i=left,j=right; int mid=a[(left+right)/2]; while(i<=j){ while(a[i]<mid)i++; while(a[j]>mid)j--; if(i<=j){ swap(a[i],a[j]); i++,j--; } } if(left<j)quicksort(a,left,j); if(i<right)quicksort(a,i,right); } int main(){ cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; quicksort(a,1,n); for(int i=1;i<=n;i++)cout<<a[i]<<' '; }