| ||||||||||
| 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 | |||||||||
为什么超时 怎么优化才行呢#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator