题解 | #简单密码#

简单密码

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

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

int main()
 {
    int a,b,c,e,f;
    char str1[100];
    char str2[100]={"\0"};//注意字符置初值,否则容易出错

    gets(str1);
    a=strlen(str1);
    e=0;
    for(c=0;c<a;c++)
    {
        if(isdigit(str1[c]))
            str2[e++]=str1[c];
        else if(islower(str1[c]))
          {
            if(str1[c]=='a'||str1[c]=='b'||str1[c]=='c')
                str2[e++]='2';
            else if(str1[c]=='d'||str1[c]=='e'||str1[c]=='f')
            str2[e++]='3';
             else if(str1[c]=='g'||str1[c]=='h'||str1[c]=='i')
            str2[e++]='4';
             else if(str1[c]=='j'||str1[c]=='k'||str1[c]=='l')
            str2[e++]='5';
             else if(str1[c]=='m'||str1[c]=='n'||str1[c]=='o')
            str2[e++]='6';
             else if(str1[c]=='p'||str1[c]=='q'||str1[c]=='r'||str1[c]=='s')
            str2[e++]='7';
             else if(str1[c]=='t'||str1[c]=='u'||str1[c]=='v')
            str2[e++]='8';
             else if(str1[c]=='w'||str1[c]=='x'||str1[c]=='y'||str1[c]=='z')
            str2[e++]='9';
          }
        else if(isupper(str1[c])&&str1[c]!='Z')
             {
                 str2[e++]=str1[c]+1+32;
             }
        else if(str1[c]=='Z')
         str2[e++]='a';
    }
        e--;
        puts(str2);
    
}

全部评论

相关推荐

明天不下雨了:把第二个项目放第一个去,其他没什么问题,多投,这世道就这样
点赞 评论 收藏
分享
神哥不得了:首先我就是在成都,成都的互联网格外的卷,如果是凭现在的简历的话很难找到大厂,建议再添加一个高质量的项目上去,另外专业技能的话最好是超过每一条的一半
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务