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

字符串字符匹配

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

#include <bits/stdc++.h>
using namespace std;

int main() {
    string str1, str2;
    getline(cin, str1);
    getline(cin, str2);
    int l1 = str1.length();
    int l2 = str2.length();
    int count = 0;
    for (int i = 0; i < l1; i++) {
        for (int j = 0; j < l2; j++) {
            if (str1[i] == str2[j]) {
                ++count;
                break;
            }
        }
    }
    if (count == l1) cout << "true" << endl;
    else cout << "false" << endl;
}

全部评论

相关推荐

豆泥🍀:同26届,加油,我也还没找到查看图片
点赞 评论 收藏
分享
04-22 15:13
已编辑
Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务