赞
踩
- #include<iostream>
-
- uisng namespace std;
-
- const int n=100001;
- int sz;
- int a[];
-
- void q_sort(int a[],int l,int r)
- {
-
-
- if(l>=r)return;
- int x=a[l];
- int i=l-1;
- int j=r+1;
- while(i<j)
- {
- do i++;while(a[i]<x);
- do j--;while(a[j]>x);
- if(i<j)swap(a[i],a[j]);
- }
- q_sort(a,l,j);
- q_sort(a,j+1,r);
- }
-
-
- int main()
- {
- cin>>sz;
- for(int i=0;i<sz;i++)
- cin>>a[i];
- q_sort(a,0,sz-1);
- for(int i=0;i<sz;i++)cput<<a[i]<<' ';
-
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。