十二题解 | #简单密码#

简单密码

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

#include<stdio.h>

int main(){

char decode[100]={0};
char*loc=decode;
while(~scanf("%c", loc))loc++;
int lenth = (loc-decode)/sizeof(char);
for(int i=0; i<lenth; i++){
    if(decode[i]>='a' && decode[i]<='c'){
        decode[i]='2';
    }
    else if(decode[i]>='d' && decode[i]<='f'){
        decode[i]='3';
    }
    else if(decode[i]>='g' && decode[i]<='i'){
        decode[i]='4';
    }
    else if(decode[i]>='j' && decode[i]<='l'){
        decode[i]='5';
    }
    else if(decode[i]>='m' && decode[i]<='o'){
        decode[i]='6';
    }
    else if(decode[i]>='p' && decode[i]<='s'){
        decode[i]='7';
    }
    else if(decode[i]>='t' && decode[i]<='v'){
        decode[i]='8';
    }
    else if(decode[i]>='w' && decode[i]<='z'){
        decode[i]='9';
    }
    else if(decode[i]>='A' && decode[i]<='Y'){
        decode[i]=decode[i]+33;
    }
    else if(decode[i]=='Z'){
        decode[i]='a';
    }
}
 for(int i=0; i<lenth; i++){
     printf("%c", decode[i]);
 }

}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务