参考代码:
#include <iostream>
#include <string>
using namespace std;
string encrypt(const string& str) {
string encrypted_str = "";
for (char c : str) {
if ((c >= 'a' && c < 'z') || (c >= 'A' && c < 'Z')) {
encrypted_str += c + 1;
} else if (c == 'z') {
encrypted_str += 'a';
} else if (c == 'Z') {
encrypted_str += 'A';
} else {
encrypted_str += c;
}
}
return encrypted_str;
}
int main() {
string str;
getline(cin, str);
string encrypted_str = encrypt(str);
cout << encrypted_str << endl;
return 0;
}
0.0分
1 人评分