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 main() { int i,j,n,x; int flag=0; cin>>n; int a[10000]; for(i=0;i<n;i++){ cin>>a[i]; } for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { if(a[i]>a[j]) { x=a[i]; a[i]=a[j]; a[j]=x; } } i=0; while(i<n) { if(a[i]==a[i+1]) { for(j=i+1;j<n;j++) a[j]=a[j+1]; n--; } else i++; } cout<<a[n/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