题解 | 简单密码
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
for (auto ch: s) {
if (ch >= 'a' && ch <= 'z') {
if (ch < 's') {
int n = (ch - 'a')/3 + 2;
cout << n;
} else {
if (ch > 's' && ch < 'w') {
cout << 8;
} else if (ch >= 'w') {
cout << 9;
} else {
cout << 7;
}
}
} else if (ch >= 'A' && ch <= 'Z') {
if ('Z' == ch) {
cout << 'a';
} else {
char m = ch + 33;
cout << m;
}
} else {
cout << ch;
}
}
}
// 64 位输出请用 printf("%lld")
查看12道真题和解析