Time Limit: 1000 ms Memory Limit: 65536 KiB
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
Hint
Source
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char a[101];
int n,i;
gets(a);
n = strlen(a);
for(i=0;i<n;i++)
{
if(a[i]<='z'&&a[i]>='a')
a[i] = a[i] - 32;
else if(a[i]<='Z'&&a[i]>='A')
a[i] = a[i] + 32;
else if(a[i]<='9'&&a[i]>='0')
a[i] = 105 -a[i]; //“9”的asll码值为105,所以105-a[i]便为题目中的要求;
}
for(i=n-1;i>=0;i--)
printf("%c",a[i]);
return 0;
}
运行结果:
china
CHINA
Process returned 0 (0x0) execution time : 4.084 s
Press any key to continue.
1230

被折叠的 条评论
为什么被折叠?



