子序列 (All in All,UVa 10340)
1 #include <iostream> 2 #include <string.h> 3 #include <string> 4 #include <fstream> 5 #include <algorithm> 6 #include <stdio.h> 7 using namespace std; 8 #define MAXN 100002 9 int main() 10 { 11 char a[MAXN],b[MAXN]; 12 while(cin>>a>>b) 13 { 14 int lena=strlen(a); 15 int lenb=strlen(b); 16 int cur=0; 17 for(int i=0;i<lenb;i++) 18 { 19 if(cur==lena)break; 20 if(b[i]==a[cur]){cur++;} 21 } 22 if(cur!=lena)printf("No\n"); 23 else printf("Yes\n"); 24 } 25 26 return 0; 27 }
眼瞎~~