题解 | #简单密码#

简单密码

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

#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
    char str[101];
    char table[] = "cfilosvz";
    scanf("%s", str);
    for (int i = 0; i < strlen(str); i++) {
        if (islower(str[i])) {
            for (int j = 0; j < 8; j++)
                if (str[i] <= table[j]) {
                    printf("%c", '2' + j);
                    break;
                }
        } else if (isupper(str[i])) {
            str[i] += str[i] == 'Z' ? -25 : 1;
            printf("%c", tolower(str[i]));
        } else
            printf("%c", str[i]);
    }
}

全部评论

相关推荐

Ncsbbss:又想干活又想要工资,怎么什么好事都让你占了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务