题解 | #简单密码#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
cin >> str;
string result;
for(char c : str) {
if(c>='a'&&c<='c') c = '2';
else if(c>='d'&&c<='f') c = '3';
else if(c>='g'&&c<='i') c = '4';
else if(c>='j'&&c<='l') c = '5';
else if(c>='m'&&c<='o') c = '6';
else if(c>='p'&&c<='s') c = '7';
else if(c>='t'&&c<='v') c = '8';
else if(c>='w'&&c<='z') c = '9';
if(c>='A') {
if(c<'Z') c = c + 32 + 1;
else if(c=='Z') c = 'a';
}
result += c;
}
cout << result << endl;
return 0;
}