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 tjdx2009 at 2012-08-12 17:24:38 on Problem 1458
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	string str1,str2;
	int i,j,len1,len2,count1,count2,point;
	
	while(cin>>str1>>str2)
	{
		len1=str1.size();
		len2=str2.size();
		i=0;count1=0;j=0;point=0;
		while(i<len1)
		{
			
			while(j<len2)
			{
				if(str1[i]!=str2[j])
					j++;
				else
				{
					count1++;
					point=j+1;
					break;
				}
			}
			
			j=point;
			i++;
				
		}
	
		i=0;count2=0;j=0;point=0;
		while(j<len2)
		{
			
			while(i<len1)
			{
				if(str1[i]!=str2[j])
					i++;
				else
				{
					count2++;
					
					point=i+1;
					break;
				}
			}
			
			i=point;
			j++;
			
		}
		
		if(count1>count2)
			cout<<count1<<endl;
		else
			cout<<count2<<endl;
	}
}

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