(Relax ST1.9)POJ 1936 All in All(判断一个字符串去掉一部分以后是否等价于另一个字符串)
这道题的思想就在于,以一个字符串为目标串,去匹配另外一个字符串
/*
* POJ_1936.cpp
*
* Created on: 2013年11月26日
* Author: Administrator
*/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 100005;
int main(){
char str1[maxn],str2[maxn];
while(scanf("%s%s",str1,str2)!=EOF){
int len1 = strlen(str1);
int len2 = strlen(str2);
int i = 0,j = 0;
while(true){
if(i == len1){
printf("Yes\n");
break;
}else if(i < len1 && j == len2){
printf("No\n");
break;
}
if(str1[i] == str2[j]){
i++;
j++;
}else{
j++;
}
}
memset(str1,0,sizeof(str1));
memset(str2,0,sizeof(str2));
}
return 0;
}