题解 | #简单密码#

简单密码

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

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

int main() {
    string input;
    while (cin >> input) {
        for (int i = 0; i < input.size(); i++) {
            int x = (int)input[i];
            if (x >= 97 && x <= 111) {
                input[i] = (char)((x - 97) / 3 + 50);
            } else if (x >= 112 && x <= 115) {
                input[i] = '7';
            } else if (x >= 116 && x <= 118) {
                input[i] = '8';
            } else if (x >= 119 && x <= 122) {
                input[i] = '9';
            } else if (x >= 65 && x < 90) {
                input[i] = (char)(x + 33);
            } else if (x == 90) {
                input[i] = 'a';
            }
        }
        cout << input << endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务