简单编码 (sdut oj)
2017-02-08 22:30
176 查看
简单编码
Time Limit: 1000MS Memory Limit: 65536KB
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
Hint
Author
参考代码
#include<stdio.h> #include<string.h> int main() { char a[101]; char b[101]; gets(a); int n = strlen(a); int i; for(i = 0; i < n; i++) { if(a[i] >= 'a' && a[i] <= 'z') { b[i] = a[i] - 32; } else if(a[i] >= 'A' && a[i] <= 'Z') { b[i] = a[i] + 32; } else if(a[i] >= 48 && a[i] <= 57) { b[i] = 105 - a[i]; } } for(i = n - 1; i >= 0; i--) { printf("%c",b[i]); } printf("\n"); return 0; }
相关文章推荐
- 简单 utf8 编码、解码,可用来对数据进行加密
- 改善编码风格(超级简单实用)
- 编码,charset,乱码,unicode,utf-8与net简单释义
- 编码,charset,乱码,unicode,utf-8与net简单释义
- 转: 编码,charset,乱码,unicode,utf-8与net简单释义(续)
- 最简单的mysql的中文编码问题
- MPEG2与MPEG4在视频编码的简单比较
- 简单的jpeg编码程序
- 简单编码解码加密解密函数
- 改善编码风格(超级简单实用)
- unicode编码的一些简单问题
- 简单编码,快速统一站点主题
- 编码,charset,乱码,unicode,utf-8与net简单释义(续)
- 简单的jpeg编码程序
- delphi中将UCS2编码的字符串转化为GB2312编码的简单方法
- C程序简单实现哈夫曼树的编码 (转)
- 编码,charset,乱码,unicode,utf-8与net简单释义(续)
- 关于编码的简单解决方式
- 转: 编码,charset,乱码,unicode,utf-8与net简单释义
- 简单的编码加密