题解 | 简单密码啰嗦解法
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
#include <iostream>
#include<string>
using namespace std;
int main() {
char s;
while (cin >> s) {
if (s >= 'a' && s <= 'z') {
if (s - 'a' >= 0 && s - 'a' < 3)s = '2';
if (s - 'a' >= 3 && s - 'a' < 6)s = '3';
if (s - 'a' >= 6 && s - 'a' < 9)s = '4';
if (s - 'a' >= 9 && s - 'a' < 12)s = '5';
if (s - 'a' >= 12 && s - 'a' < 15)s = '6';
if (s - 'a' >= 15 && s - 'a' < 19)s = '7';
if (s - 'a' >= 19 && s - 'a' < 22)s = '8';
if (s - 'a' >= 22 && s - 'a' <26)s = '9';
}
if (s >= 'A' && s < 'Z') {
s = s + 33;
}
if(s=='Z')s='a';
cout << s;
}
}
// 64 位输出请用 printf("%lld")
是可以用两个数组对应密码本的,但感觉就这么点字母没必要。


