简单遍历替换字符

字符串的反码

http://www.nowcoder.com/questionTerminal/01b7dae14d1b464db5f9259e90d9a35e

#include <stdio.h>
#include <string.h>
int main(){
    char s[80];
    int i,c;
    while(scanf("%s",&s)!=EOF){
        if(!strcmp(s,"!")) break;
        for(i=0;i<strlen(s);i++){
            if(s[i]>='a'&&s[i]<='m')
            {
                c=s[i]-'a';
                s[i]='z'-c;
            }
            else if(s[i]>='n'&&s[i]<='z')
            {
                c='z'-s[i];
                s[i]='a'+c;
            }
            else if(s[i]>='A'&&s[i]<='M')
            {
                c=s[i]-'A';
                s[i]='Z'-c;
            }
            else if(s[i]>='N'&&s[i]<='Z')
            {
                c='Z'-s[i];
                s[i]='A'+c;
            }            
        }
        printf("%s\n",s);
    }
}
(•̀ᴗ•́)و
全部评论

相关推荐

与火:这不接? 留子的钱不挣白不挣
点赞 评论 收藏
分享
评论
2
收藏
分享
牛客网
牛客企业服务