题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/ff99c43dd07f4e95a8f2f5448da3772a
#include <iostream> #include <string> #include <cstdio> using namespace std; int main() { string start, str, end; while (getline(cin,str)) { if (start == "ENDOFINPUT") { break; } getline(cin, str); for (int i = 0; i < str.size(); i++) { if (str[i] <= 'Z' && str[i] >= 'A') { str[i] = 'A' + ((str[i] - 'A' - 5) + 26) % 26; } } cout << str << endl; cin >> end; } return 0; } // 64 位输出请用 printf("%lld")
cin>>str
换行不算字符串结尾,只有空格才算结尾
getline(cin,str)换行才算结尾
考研复试机试 文章被收录于专栏
考研复试机试