题解 | #简单密码#

简单密码

https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac

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

int main() {
    string s;
    cin>>s;
    for (char& ch : s) {
        if (ch >= 'a' && ch <= 'z') {
            if (ch <= 'c')
                ch = '2';
            else if (ch <= 'f')
                ch = '3';
            else if (ch <= 'i')
                ch = '4';
            else if (ch <= 'l')
                ch = '5';
            else if (ch <= 'o')
                ch = '6';
            else if (ch <= 's')
                ch = '7';
            else if (ch <= 'v')
                ch = '8';
            else
                ch = '9';
        }
        else if(ch>='A' && ch<='Z')
        {
            ch = 'a' + (ch-'A'+1)%26;
        }
    }

    cout<<s;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务