简单编码
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
然后将所有字符的顺序颠倒。
将原来的小写字母全部翻译成大写字母,大写字母全部翻译成小写字母,数字的翻译规律如下:
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
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,n;
char a[100],t;
scanf("%s",a);
n=0;
for (i=0; i<=99; i++)
{
if (a[i]>=65&&a[i]<=90) a[i]=a[i]+32;
else if (a[i]>=97&&a[i]<=122) a[i]=a[i]-32;
else if (a[i]>=48&&a[i]<=57) a[i]=105-a[i];
}
for(i=0; a[i]!='\0'; i++)
{
n=n+1;
}
for (i=0; i<=(n-1)/2; i++)
{
t=a[i];
a[i]=a[n-1-i];
a[n-1-i]=t;
}
printf("%s\n",a);
return 0;
}