题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
#include <iostream>
using namespace std;
int main() {
string a_z = "22233344455566677778889999";
string password;
while (cin >> password) {
for (size_t i = 0; i < password.length(); ++i) {
char c = password[i];
if ('a' <= c && c <= 'z') {
password[i] = a_z[c - 'a'];
} else if ('A' <= c && c <= 'Z') {
if (c < 'Z') {
password[i] = c + 1 + 32;
} else {
password[i] = 'a';
}
}
}
cout << password << endl;
}
}
// 64 位输出请用 printf("%lld")

查看24道真题和解析