题解 | #密码翻译#
密码翻译
https://www.nowcoder.com/practice/136de4a719954361a8e9e41c8c4ad855
#include <iostream> #include <string> using namespace std; /** *输入空格、回车参考链接:http://t.csdn.cn/lq5JY **/ char convert(char a){ if(a >= 'a' && a <= 'z' || a >= 'A' && a <= 'Z'){ if(a == 'z' || a == 'Z') return a - 25; else return a + 1; } return a; } int main() { string str; while (getline(cin, str)) { // 注意 while 处理多个 case for (int i = 0; i < str.length(); i ++) { cout << convert(str[i]); } cout << endl; } return 0; } // 64 位输出请用 printf("%lld")