题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
当然要拍照记录啊
#include<iostream> #include<string> using namespace std; int main() { string s; cin >> s; int i = 0; for (char c : s) { if (c >= 'a' && c <= 'p') { c = (c - 'a') / 3 + 2 + '0'; } else if (c >= 'q' && c <= 'y') { c = (c - 'q') / 3 + 7 + '0'; } else if (c == 'z') c = '9'; else if (c >= 'A' && c <= 'Y') c += 33; else if (c == 'Z') c = 'a'; s[i] = c; i++; } cout << s; return 0; }