来源:http://poj.org/problem?id=1936
题意:判断一个串是否是另一个串的子串
思路:水题啊,,,直接用string的find函数就可以了
代码:
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(){
freopen("1.txt","r",stdin);
string s1,s2;
while(cin>>s1>>s2){
int len1 = s1.size();
int pos = 0,flag = 1;
for(int i = 0;i < len1;++i){
int cnt = s2.find(s1[i],pos);
if(cnt == s2.npos){
flag = 0;
break;
}
else{
pos = cnt+1;
}
}
if(flag == 1)printf("Yes\n");
else printf("No\n");
}
return 0;
}