题解 | 字符串加密

字符串加密

https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3

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

int main() {
    string encrypt;
    getline(cin, encrypt);
    string text;
    getline(cin, text);
    string mode = "";
    unordered_set<char> mark;
    for(char& c : encrypt){
        if(!mark.count(c)){
            mode += c;
            mark.emplace(c);
        }
    }
    for(int i=0; i<27; ++i){
        char c = 'a' + i;
        if(!mark.count(c)){
            mode += c;
            mark.emplace(c);
        }
    }

    for(char& c : text){
        cout << mode[c-'a'];
    }
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

不知道怎么取名字_:玩游戏都写到简历上了啊
投递BOSS直聘等公司9个岗位
点赞 评论 收藏
分享
12-19 22:04
武汉大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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