题解 | 字符串加密
字符串加密
https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { string s, t; cin >> s >> t; vector<char> res; for(char c: s) { if(find(res.begin(), res.end(), c) == res.end()) { res.push_back(c); } } for(char c = 'a'; c <= 'z'; ++c) { if(find(res.begin(), res.end(), c) == res.end()) { res.push_back(c); } } for(size_t i = 0; i < t.size(); ++i) { t[i] = res[t[i] - 'a']; } cout << t << endl; return 0; }