题解 | #字符串字符匹配#
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
#include <iostream> using namespace std; #include <string> int main() { string s, l; getline(cin, s); getline(cin, l); for (char i : s) { bool flag = false; for (char j : l) { if (i == j) { flag = true; } } if (!flag) { cout << "false" << endl; return 0; } } cout << "true" << endl; }
直接暴力搜索,也可以用string的find
华为机试刷题记录 文章被收录于专栏
记录一下手打代码的解题思路方便复习