| ||||||||||
| 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 | |||||||||
求助!!测试无错,但是就是WA!为什么啊?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator