题目:判断a串是不是b串的子串。
代码:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
string s1,s2;
int main() {
while(cin>>s1>>s2) {
int flag = 0;
bool change;
for(int i=0; i<s1.size(); i++) {
change = false;
for(int j=flag; j<s2.size(); j++) {
if(s1[i]==s2[j]) {
flag = j+1;
change = true;
break;
}
}
if(!change) break;
}
if(change) printf("Yes\n");
else printf("No\n");
}
return 0;
}
判断子串算法
202

被折叠的 条评论
为什么被折叠?



