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 yanzhu at 2009-07-30 20:28:24 on Problem 1159
#include<iostream>
using namespace std;
int main()
{
 int n,count,max,cur,cur1,max1;
 char a[5000];
 cin>>n;
 for(int i=0;i<n;i++)
	 cin>>a[i];

 max=0;
 for(int i12=1;i12<n-1;i12++)
 {
	 cur=0;cur1=i12+1;
	 for(int i22=i12-1;i22>=0;i22--)
	 {
	    
		if(cur1<n)
		{
		  if(a[i22]==a[cur1])
			  cur++;
		}
		cur1++;
	 }
	 if(max<cur)
		 max=cur;
 }
 max1=0;
 for(int i1=0;i1<n-1;i1++)
 {
	 cur=0;cur1=i1+1;
	 for(int i2=i1;i2>=0;i2--)
	 {
	    
		if(cur1<n)
		{
		  if(a[i2]==a[cur1])
			  cur++;
		  
		}
		cur1++;
	 }
	 if(max1<cur)
		 max1=cur;
 }
 if(max==n/2||max1==n/2)
	 cout<<"0"<<endl;
 else
 {
 if(max>max1)
   cout<<n+1-2*(max+1)<<endl;
 else
	 cout<<(n-2*max1)<<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