#简单密码#__huawei-no.21-1
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
#include <iostream> #include <vector> using namespace std; int main() { string str; getline(cin, str); vector<string>str_2; string temp; for (char c : str) { if (c >= 'a' && c <= 'c' ) { temp = '2'; str_2.push_back(temp); } else if (c >= 'd' && c <= 'f') { temp = '3'; str_2.push_back(temp); } else if (c >= 'g' && c <= 'i') { temp = '4'; str_2.push_back(temp); } else if (c >= 'j' && c <= 'l') { temp = '5'; str_2.push_back(temp); } else if (c >= 'm' && c <= 'o') { temp = '6'; str_2.push_back(temp); } else if (c >= 'p' && c <= 's') { temp = '7'; str_2.push_back(temp); } else if (c >= 't' && c <= 'v') { temp = '8'; str_2.push_back(temp); } else if (c >= 'w' && c <= 'z') { temp = '9'; str_2.push_back(temp); } else if(c >= '0' && c <= '9'){ temp = c; str_2.push_back(temp); } else if(c >= 'A' && c < 'Z'){ temp = c + 32 + 1; str_2.push_back(temp); } else if ( c == 'Z'){ temp = 'a'; str_2.push_back(temp); } } for(auto & i : str_2){ cout<<i; } return 0; } // 64 位输出请用 printf("%lld")
简单纯粹的暴力解法,而且很多麻烦,temp也可以不要,实际上。