SDUT-1187:简单编码

简单编码

Problem Description

将一串文本译成密码,密码的规律是:
将原来的小写字母全部翻译成大写字母,大写字母全部翻译成小写字母,数字的翻译规律如下:

0——>9
1——>8
2——>7
3——>6
4——>5
5——>4
6——>3
7——>2
8——>1
9——>0

然后将所有字符的顺序颠倒。

Input

输入一串文本,最大字符个数不超过100。

Output

输出编码后的结果。

Sample Input

china

Sample Output

ANIHC

#include <stdio.h>
#include <string.h>
int main()
{
   char a[105];
   int i,j,m;
   gets(a);
   m=strlen(a);
   for(i=0;i<m;i++)
   {
        if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z'))
            if(a[i]>='a'&&a[i]<='z')
                a[i]-=32;
            else
                a[i]+=32;
        else if(a[i]>='0'&&a[i]<='9')
            switch(a[i])
            {
                case '0':a[i]='9';break;
                case '1':a[i]='8';break;
                case '2':a[i]='7';break;
                case '3':a[i]='6';break;
                case '4':a[i]='5';break;
                case '5':a[i]='4';break;
                case '6':a[i]='3';break;
                case '7':a[i]='2';break;
                case '8':a[i]='1';break;
                case '9':a[i]='0';break;
            }
   }
    for(j=m-1;j>=0;j--)
        printf("%c",a[j]);
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值