题解 | #字符串加密#
字符串加密
https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
#include <iostream> using namespace std; int main() { string str; string strafter; string strkey; cin >> str; cin >> strkey; for (auto &it : str) { if (string::npos == strafter.find(it)) { strafter += it; } } for (char ch = 'a'; ch <= 'z'; ch++) { if (string::npos == strafter.find(ch)) { strafter += ch; } } string strout; for (char ch : strkey) { int n = ch - 'a'; strout += strafter[n]; } cout << strout; return 0; } // 64 位输出请用 printf("%lld")