题解 | #密码翻译#
密码翻译
https://www.nowcoder.com/practice/136de4a719954361a8e9e41c8c4ad855
#include<cstdio> #include<string> using namespace std ; int main() { char arr[100]; fgets(arr, 100, stdin); string str = arr ; for (unsigned i = 0 ; i < str.size() ; ++ i ) { if (str[i] >= 'a' && str[i] < 'z' || str[i] > 'A' && str[i] < 'Z') { str[i] = str[i] + 1; } else if (str[i] == 'z' ) { str[i] = 'a'; } else if ( str[i] == 'Z') { str[i] = 'A'; } else { str[i] = str[i]; } } printf("%s", str.c_str()); }