Sample Output
5 4 3 2 1
#include"iostream"
#include"cstdio"
#include"cstring"
#include"cstdlib"
using namespace std;
int que[1000100];
int n;
void Qsort(int s[],int low,int high)
{
int i=low,j=high;
s[0]=s[low];
while(low<high)
{
while(low<high&&s[high]<=s[0])high--;
if(low<high)s[low++]=s[high];
while(low<high&&s[low]>=s[0])low++;
if(low<high)s[high]=s[low];
}
s[low]=s[0];
if(low>i)Qsort(s,i,low-1);
if(low<j)Qsort(s,low+1,j);
}
int main()
{memset(que,'\0',sizeof(que));
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&que[i]);
Qsort(que,1,n);
for(int i=1;i<n;i++)
printf("%d ",que[i]);
printf("%d\n",que[n]);
return 0;
}