题解 | #字符串加密#
字符串加密
https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
#include <algorithm> #include <any> #include <iostream> #include <string> #include <vector> using namespace std; int charToint(char c) { return c-'a'; } int main() { string key; string s; cin >> key >> s; vector<char> res; for(char c : key) { if(count(res.begin(), res.end(), c) == 0) { res.push_back(c); } } for(char c = 'a'; c <= 'z'; c++) { if(count(res.begin(), res.end(), c) == 0) { res.push_back(c); } } string ans; for(char c : s) { ans.push_back(res[charToint(c)]); } cout << ans; } // 64 位输出请用 printf("%lld")