这道题目是不是从长字符串中匹配子串的问题,而是一个更简单的问题。
C++代码如下:
#include<iostream> #include<string> using namespace std; int main() { string sShort = ""; string sLong = ""; while (cin >> sShort >> sLong) { int i = 0; for (; i < sShort.size(); i++) { if (sLong.find(sShort[i]) == -1) { cout << "false" << endl; break; } } if (i == sShort.size()) cout << "true" << endl; } return 0; }