简单编码

来源:互联网 发布:苏宁抢购软件 编辑:程序博客网 时间:2024/05/02 03:03

 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

 Author

zyx

 Recommend

zh
#include <stdio.h> #include <string.h> #include <ctype.h>int main() { int i,length;  char a[101]; while(scanf("%[^\n]%*c",&a)!=EOF){length=strlen(a);for(i=0;i<length;i++) {if(a[i]<='z' && a[i]>='a') { a[i]=toupper(a[i]);} else if(a[i]<='Z' && a[i]>='A') { a[i]=tolower(a[i]); } else if(a[i]<='9' && a[i]>='0') { a[i]=105-a[i]; }} for(i=length-1; i>=0; i--) { printf("%c", a[i]); } printf("\n");}return 0; } 


0 0
原创粉丝点击