Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么是WA,求大牛帮忙。。

Posted by silentwinna at 2012-05-18 22:55:06 on Problem 2388
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator