题解 | #简单密码#

简单密码

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

/***************
*笨方法,可以采用数组列举对应关系查表法简便。
***************/
#include <stdio.h>
#include <string.h>
int main() {
    char str[101];
    char str1[101];
    int len = 0, i, j;
    scanf( "%s", str );
    len = strlen(str);
    for( i = 0; i<len; i++ )
    {
        if( str[i] == 1 )
            str1[i] = '1';
        else if( str[i] == 'a' || str[i] == 'b' || str[i] == 'c' )
            str1[i] = '2';
        else if( str[i] == 'd' || str[i] == 'e' || str[i] == 'f' )
            str1[i] = '3';
        else if( str[i] == 'g' || str[i] == 'h' || str[i] == 'i' )
            str1[i] = '4';
        else if( str[i] == 'j' || str[i] == 'k' || str[i] == 'l' )
            str1[i] = '5';
        else if( str[i] == 'm' || str[i] == 'n' || str[i] == 'o' )
            str1[i] = '6';
        else if( str[i] == 'p' || str[i] == 'q' || str[i] == 'r' || str[i] == 's')
            str1[i] = '7';
        else if( str[i] == 't' || str[i] == 'u' || str[i] == 'v' )
            str1[i] = '8';
        else if( str[i] == 'w' || str[i] == 'x' || str[i] == 'y'|| str[i] == 'z' )
            str1[i] = '9';
        else if( str[i] == '0' )
            str1[i] = '0';
        else if( str[i] >= 'A' && str[i] < 'Z' )
            str1[i] = 'a' - 'A' + str[i] + 1; 
        else if( str[i] == 'Z' )
            str1[i] = 'a';
        else 
            str1[i] = str[i];
    }
    for( i = 0; i<len; i++ )
        printf( "%c", str1[i] );
    return 0;
}

全部评论

相关推荐

尊嘟假嘟点击就送:加v细说,问题很大
点赞 评论 收藏
分享
吃不饱的肱二头肌很想退休:tnnd 我以为选妹子呢,亏我兴高采烈的冲进来😠
投递快手等公司10个岗位
点赞 评论 收藏
分享
预计下个星期就能开奖吧,哪位老哥来给个准信
华孝子爱信等:对接人上周说的是这周
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务