C++,无序集合unordered_set

字符串字符匹配

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

#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;
int main(){
    string shortS,longS;
    bool res;
    while(cin >> shortS >> longS){
        unordered_set<char> set;
        for(char c:longS){
            set.insert(c);
        }
        res=true;
        for(char c:shortS){
            if(!set.count(c)){
                res=false;
                break;
            }
        }
        //boolalpha操纵符改变布尔值格式
        cout << boolalpha << res <<endl;
    }
    return 0;
}
全部评论

相关推荐

点赞 评论 收藏
分享
评论
22
1
分享

创作者周榜

更多
牛客网
牛客企业服务