题解 | #字符串合并处理#
当然要拍照记录啊
#include <iostream> #include <string> #include <algorithm> using namespace std; char change(char c) { string s1, s2; s1 = "1234578abcdefABCDE"; s2 = "84C2AE15D3B7F5D3B7"; int i = 0; for (char a : s1) { if (a == c) return s2[i]; i++; } return c; } int main() { string str1, str2, s; cin >> str1 >> str2; s = str1 + str2; str1.clear(); str2.clear(); for (int i = 0; i < s.size(); i++) { str1.push_back(s[i]); i++; if (i < s.size()) str2.push_back(s[i]); } s.clear(); sort(str1.begin(), str1.end()); sort(str2.begin(), str2.end()); for (int i = 0; i < str1.size(); i++) { s.push_back(str1[i]); if (i < str2.size()) s.push_back(str2[i]); } int n = 0; for (char c : s) { s[n] = change(c); n++; } cout << s << endl; }