题解 | #字符串字符匹配#

字符串字符匹配

https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93

  • 再来个C++版本,防止python3到时候搞不定
#include <iostream>
#include <set>
using namespace std;

int main() {
    string s, t;
    bool flag;
    while (cin >> s >> t) { // 注意 while 处理多个 case
        set<char> set;

        for (char ch : t) {
            set.insert(ch);
        }
        flag = true;
        for (char ch : s) {
            if (!set.count(ch)) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << "true" << endl;
        }
        else {
            cout << "false" << endl;
        }
    }
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

02-23 00:10
湖南大学 C++
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务