#include<stdio.h> #include<string> #include<string.h> #include<iostream> using namespace std; string s1,s2; int main() { char a[200]; char b[200]; int i,j,k; while(scanf("%s %s",a,b+1)!=EOF) { b[0]='*';//正确密码的片段(可能首缺) s1=a; s2=b; i=0,j=0,k=0; //s2.push_front(*); while(i<s1.size()&&j<s2.size()) { while(i<s1.size()&&j<s2.size()&&s1[i]==s2[j]) { i++;j++; } if(i<s1.size()&&j<s2.size()&&s2[j]!='*') { if(k==0) { //printf("no\n"); break; } else { j=k; while(i<s1.size()&&j<s2.size()&&s1[i]!=s2[j])i++; } } else if(i<s1.size()&&j<s2.size()) { while(s2[j]=='*')//连续的‘*’,当做一个‘*’看 j++; k=j; while(i<s1.size()&&j<s2.size()&&s1[i]!=s2[j])i++; } } if(j==s2.size())printf("yes\n"); else printf("no\n"); s1.clear(); s2.clear(); memset(b,true,sizeof(b)); memset(a,true,sizeof(a)); } return 0; }
http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1163