include[HTML_REMOVED]
using namespace std;
const int N=100010;
int n,a[N];
void quick_sort(int i,int j)
{
if(i>=j)
return;
int x=a[i],l=i,r=j;
while(l[HTML_REMOVED]x) –r;
if(l<r)
{swap(a[l],a[r]);l;–r;};
}
quick_sort(i,r),quick_sort(r+1,j);
}
int main()
{
scanf(“%d”,&n);
for(int i=0;i<n;i)scanf(“%d”,&a[i]);
quick_sort(0,n-1);
for(int i=0;i<n;i++)printf(“%d “,a[i]);
return 0;
}
输入
5
1 3 4 5 2
输出
1 2 3 5 4