文章
13
粉丝
120
获赞
37
访问
23.0k
简单解密
1. 注意溢出的情况
2. 大小写问题
解密公式
char((a - 'A' - 5 + 26) % 26 + 'A');
完整代码
#include<iostream>
using namespace std;
char cal(char a)
{
	return char((a - 'A' - 5 + 26) % 26 + 'A');
}
int main()
{
	string s;
	while(getline(cin,s) and s != "ENDOFINPUT")
	{
		if(s != "START" and s != "END")
		{
			for(auto x:s)
			{
				if(isalpha(x))cout << cal(x);
				else cout << x;
			}
			cout << endl;
		}
	}
	
	return 0;
}
登录后发布评论
暂无评论,来抢沙发