题解 | #字符串加密#
字符串加密
https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
#include<bits/stdc++.h>
using namespace std;
int main() {
vector<char> vec;
vector<bool> vecflag(26, false);
string input;
string key;
cin >> key >> input;
for (auto c : key) {
char cc = tolower(c);
if (!vecflag[cc - 'a']) {
vec.push_back(cc);
vecflag[cc - 'a'] = true;
}
}
for (char c = 'a'; c <= 'z'; c++) {
if (!vecflag[c - 'a'] ) {
vec.push_back(c);
vecflag[c - 'a'] = true;
}
}
string output = "";
for (auto sc : input) {
if (islower(sc)) {
output += vec[sc - 'a'];
} else {
output += vec[sc - 'A'] - 32;
}
}
cout << output << endl;
// for (auto c : vec) {
// cout << c << " ";
// }
// cout << endl << "vec.size():" << vec.size() << endl;
}
360集团公司氛围 407人发布
查看8道真题和解析