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 CCUT06 at 2008-11-25 21:41:42 on Problem 2774
#include<iostream>
#include<string>

using namespace std;

int main()
{
	string 	start,
			end;
	int 	num,
			maxlength,
			minlength,
			i,
			j,
			maxsize(0);

	cin>>start;
	cin>>end;
	minlength = start.length();
	maxlength = end.length();
	
	for(i = 0;i < minlength;i ++)
	{
		
		for(j = 0;j < maxlength;j ++)
		{
			num = 0;
			while(start[i] == end[j] && j < maxlength&&i < minlength)
			{
				i ++;
				j ++;
				num ++;
			}
			if(maxsize < num)
			{
				maxsize = num;
			}
		}
	}
	cout<<maxsize<<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