密码战

题目描述 Description

在各国谍报人员之间经常进行破译密码的战斗,为了防止其他的人员破译,A国的人员使用这样的密码转化规则: 1. 对于字母字符,将其转换成其后的第3个字母。例如:A--D,a--d,X--A,x--a; 2. 对于非字母字符,保持不变。 我们国家的人员成功的截取了这条密码,请帮助破译密码。

输入描述 Input Description

A国进行加密后的字符串

输出描述 Output Description

加密前的字符串

样例输入 Sample Input

L(2017)oryh(10)Fklqd(01)!

样例输出 Sample Output

I(2017)love(10)China(01)!

数据范围及提示 Data Size & Hint

字符串长度不超过50

 1 #include <iostream>
 2 #include <cstring>
 3 #include <cstdio>
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     char s[52];
 9     gets(s);
10 
11     for(int i=0;i<strlen(s);i++)
12     {
13         if(s[i]>='a' && s[i]<='z')
14             s[i]=(s[i]-3-'z')%26 + 'z';
15         else if(s[i]>='A' && s[i]<='Z')
16             s[i]=(s[i]-3-'Z')%26 + 'Z';
17     }
18 
19     puts(s);
20     return 0;
21 }

猜你喜欢

转载自www.cnblogs.com/zhangjs73/p/10218129.html