SDUT-1187 简单编码

来源:互联网 发布:如何在淘宝上赚运费险 编辑:程序博客网 时间:2024/05/24 00:37

简单编码

Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic Discuss

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

输出编码后的结果。

Example Input

china

Example Output

ANIHC

Code

#include <stdio.h>#include <string.h>int main(){    char s[101];    int len,i;    gets(s);    len=strlen(s);    for(i=0; i<len; i++)    {        if(s[i]>='a'&&s[i]<='z')            s[i]-=32;        else if(s[i]>='A'&&s[i]<='Z')            s[i]+=32;        else if(s[i]>='0'&&s[i]<='9')            s[i]=105-s[i];    }    for(i=len-1; i>=0; i--)        printf("%c",s[i]);    printf("\n");    return 0;}


原创粉丝点击