题解 | 字符串加密
字符串加密
https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
string t;
getline(cin, s);
getline(cin, t);
string result = "";
bool alp[26] = {false};
for (int i = 0; i < s.size(); i++) {
char a = s[i];
int digit = s[i] - 'a';
if (s[i] <= 'z' && s[i] >= 'a' && !alp[digit]) {
result += a;
alp[digit] = true;
}
}
for (int i = 0; i < 26; i++) {
if (alp[i] == false) {
char a = i + 'a';
result += a;
}
}
string result1 = "";
for (int i = 0; i < t.size(); i++) {
int n = t[i] - 'a';
result1 += result[n];
}
cout << result1 << endl;
}// 64 位输出请用 printf("%lld")
