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

字符串字符匹配

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

#include <iostream>
#include <string>
using namespace std;

int main() {
    string a, b;
    while (cin >> a >> b) {
        if (b.find(a) != -1) {
            cout << "true" << endl;
            continue;
        }
        int c[26];
        for (int i = 0; i < 26; i++)
            c[i] = 0;
        for (int i = 0; i < b.length(); i++)
            c[b[i] - 'a'] = 1;
        bool d = true;
        for (int i = 0; i < a.length(); i++)
            if (c[a[i] - 'a'] != 1)
                d = false;
        if (d)
            cout << "true" << endl;
        else
            cout << "false" << endl;
    }
}

全部评论

相关推荐

用微笑面对困难:只要你保证项目和获奖都是真的就行尤其是“对战,总负责人”啊这些套职,基本上队员,打杂的都这么写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务