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 |
为什么是WA,求大牛帮忙。。#include<iostream> using namespace std; int a[10010]; void sort(int x,int y) { if(x>=y) return; int i=x,j=y; int temp=a[x]; while(i<j) { if(i<j&&temp<=a[j]) j--; a[i]=a[j]; if(i<j&&temp>=a[i]) i++; a[j]=a[i]; } a[x]=temp; sort(x,i-1); sort(i+1,y); return; } int main() { int N,i; cin>>N; for(i=0;i!=N;i++) cin>>a[i]; sort(0,N-1); cout<<a[(N-1)/2]<<endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator