题解 | 简单密码
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
#include <iostream> #include <string> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; for(auto c : s) { if(c >= '0' && c <= '9') { cout << c; } else if(c >= 'A' && c <= 'Z') { if(c == 'Z') { cout << 'a'; } else cout << (char)(c + 33); } else { if(c >='a' && c <= 'c') { cout << 2; } else if(c >='d' && c <= 'f') { cout << 3; } else if(c >='g' && c <= 'i') { cout << 4; } else if(c >='j' && c <= 'l') { cout << 5; } else if(c >='m' && c <= 'o') { cout << 6; } else if(c >='p' && c <= 's') { cout << 7; } else if(c >='t' && c <= 'v') { cout << 8; } else if(c >='w' && c <= 'z') { cout << 9; } } } cout << endl; return 0; } // 64 位输出请用 printf("%lld")
额,这道题不知道有没有什么简单的写法,感觉我写烦了。有的话,一定要告诉我啊。再加点字数,再加点,再加点,好了,差不多了。#牛客春招刷题训练营#
#牛客春招刷题训练营#