#include <iostream> #include <vector> using namespace std; bool isUpperCase(char c){ return c >= 'A' && c <= 'Z'; } int main() { string key, s; while (cin >> key >> s) { vector<char> alphabet(26, '0'); vector<bool> vis(26, false); int j = 0; for(int i = 0; i < key.size(); i++){ if(!vis[key[i] - 'a']){ alphabet[j++] = key[i]; vis[key[i] - 'a'] = true; } } char c = 'a'; while(c <= 'z' && j < 26){ if(vis[c - 'a']) { c++; continue; } alphabet[j++] = c++; } string ans; for(char c: s){ ans += alphabet[c - 'a']; } cout << ans << endl; } return 0; } // 64 位输出请用 printf("%lld")
构建字母表