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 00448322 at 2005-04-27 18:00:38 on Problem 1936
#include <iostream.h>
#include <string.h>

void main()
{
	int i,j,total;
	char str1[50],str2[50];
	int len1,len2;
	cin>>str1>>str2;
	while(cin)
	{
		j=0;
		total=0;
		len1=strlen(str1);
		len2=strlen(str2);
		for(i=0;i<len1;i++)
		{
			for(;j<len2;j++)
			{
				if(str1[i]==str2[j])
				{
					total++;
					break;
				}
			}
		}
		if(total==len1)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
		cin>>str1>>str2;
	}
}


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