题解 | 简单密码

#include <iostream>
#include <string>
using namespace std;

int main() {
    string s;
    cin >> s;
    for (auto ch: s) {
        if (ch >= 'a' && ch <= 'z') {
            if (ch < 's') {
                int n = (ch - 'a')/3 + 2;
                cout << n;
            } else {
                if (ch > 's' && ch < 'w') {
                    cout << 8;
                } else if (ch >= 'w') {
                    cout << 9;
                } else {
                    cout << 7;
                }
            }
        } else if (ch >= 'A' && ch <= 'Z') {
            if ('Z' == ch) {
                cout << 'a';
            } else {
                char m = ch + 33;
                cout << m;
            }
        } else {
            cout << ch;
        }
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

海螺很能干:每次看到这种简历都没工作我就觉得离谱
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务