题解 | #简单密码#

简单密码

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

#include <stdio.h>

int main() {
    int a, b;
    char str[105];

    scanf("%s",str);
    for(int i=0;str[i]!='\0';i++){
        if(str[i]>='0'&&str[i]<='9'){
            printf("%c",str[i]);
        }
        else if(str[i]>='a'&&str[i]<='c'){
            printf("2");
        }
        else if(str[i]>='d'&&str[i]<='f'){
            printf("3");
        }
        else if(str[i]>='g'&&str[i]<='i'){
            printf("4");
        }
        else if(str[i]>='j'&&str[i]<='l'){
            printf("5");
        }
        else if(str[i]>='m'&&str[i]<='o'){
            printf("6");
        }
        else if(str[i]>='p'&&str[i]<='s'){
            printf("7");
        }
        else if(str[i]>='t'&&str[i]<='v'){
            printf("8");
        }
        else if(str[i]>='w'&&str[i]<='z'){
            printf("9");
        }
        else if(str[i]=='Z'){
            printf("a");
        }
        else{
            printf("%c",str[i]-'A'+'a'+1);
        }
    }
    return 0;
}

全部评论

相关推荐

03-25 19:00
东北大学 Java
程序员牛肉:太好了,是聊天记录。不得不信了。 当个乐子看就好,不要散播焦虑
点赞 评论 收藏
分享
找到实习就改名4月17日下午更改:1600一个月?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务