题解 | 字符串加密
字符串加密
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")
腾讯成长空间 5950人发布