1 #include <bits/stdc++.h> 2 using namespace std; 3 int a[100]; 4 int n; 5 inline int read() 6 { 7 int x=0,f=1; 8 char ch=getchar(); 9 while(ch<'0'||ch>'9') 10 { 11 if(ch=='-') 12 f=-1; 13 ch=getchar(); 14 } 15 while(ch>='0'&&ch<='9') 16 { 17 x=x*10+ch-'0'; 18 ch=getchar(); 19 } 20 return x*f; 21 } 22 inline void write(int x) 23 { 24 if(x<0) 25 { 26 putchar('-'); 27 x=-x; 28 } 29 if(x>9) 30 { 31 write(x/10); 32 } 33 putchar(x%10+'0'); 34 } 35 inline void quicksort(int left,int right) 36 { 37 int i,j,t,temp; 38 if(left>right) 39 return; 40 temp=a[left]; 41 i=left; 42 j=right; 43 while(i!=j) 44 { 45 while(a[j]>=temp&&i<j) 46 j--; 47 while(a[i]<=temp&&i<j) 48 i++; 49 if(i<j) 50 swap(a[i],a[j]); 51 } 52 a[left]=a[i]; 53 a[i]=temp; 54 quicksort(left,i-1); 55 quicksort(i+1,right); 56 } 57 int main() 58 { 59 cin>>n; 60 for(int i=1;i<=n;i++) 61 cin>>a[i]; 62 quicksort(1,n); 63 for(int i=1;i<=n;i++) 64 cout<<a[i]<<" "; 65 return 0; 66 }