#include <iostream> using namespace std; int st[26]; char sd[26]; int main() { string s1,s2; cin>>s1>>s2; string res = ""; for(int i = 0;i<s1.length();i++){ if(st[s1[i]-'a']==1){ continue; } else { res+=s1[i];st[s1[i]-'a'] = 1; } } for(int i = 0;i<=25;i++){ if(st[i]==0){ res+=(i+'a'); } } for(int i = 0;i<=25;i++){ sd[i] = res[i]; } for(int i = 0;i<s2.length();i++){ cout<<sd[s2[i]-'a']; } // cout<<res<<'\n'; return 0; } // 64 位输出请用 printf("%lld")
首先进行去重操作,然后加上未读取的字符,与标准数组进行对应,然后遍历t,输出相应字母对应的字符即可。