挨个儿对着比就行,暴力。
#include <iostream> #include <string> using namespace std; int main() { string a, b; while (cin>>a>>b) { unsigned long i, j, len1, len2; len1 = a.length(); len2 = b.length(); i = j = 0; while (true) { if (i == len1) { cout << "Yes" << endl; break; } else if (i < len1 && j == len2) { cout << "No" << endl; break; } if (a[i] == b[j]) { i++;j++; } else j++; } } return 0; }