题解 | #简单密码#这题太奇怪了
简单密码
https://www.nowcoder.com/practice/ff99c43dd07f4e95a8f2f5448da3772a
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main() {
string str;
while (getline(cin, str)) { // 注意 while 处理多个 case
if (str == "ENDOFINPUT") {
break;
}
getline(cin, str);
//'A' 是 65
//'Z' 是 90
for (int i = 0; i < str.size(); i++) {
if (str[i] >= 'A' && str[i] <= 'Z') {
str[i] -= 5;
if (str[i] < 65) {
str[i] = str[i] + 26;
}
}
}
cout << str << endl; //endl加个换行的意思
getline(cin, str); //结束符
}
}
// 64 位输出请用 printf("%lld")
用c风格的输入不行,被迫采用c++风格
