Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
好伤心,连个快排找数都写不出来~include<iostream> using namespace std; int n; int a[10000]={0}; int qsort(int c,int b,int m) { int i=c,j=b; if(i==j)return a[i]; int mid=a[(i+j)>>1]; while(i<j) { while(a[i]<mid)i++; while(a[j]>mid)j--; if(i<=j) { swap(a[i],a[j]); i++; j--; } } if((i+j)/2==m)return a[m]; else { if(i<m)qsort(i,b,m); if(j>m)qsort(c,j,m); } } int main() { while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++)scanf("%d",&a[i]); int t=qsort(0,n-1,(n-1)/2); printf("%d",t); } } 怎么错的啊 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator