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

为什么会错

Posted by KONGJING0815 at 2007-05-15 22:11:57 on Problem 2388
#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:
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