文章

49

粉丝

49

获赞

8

访问

11.6k

头像
加密算法 题解:C++
P1014 华南师范大学/贵州大学机试题
发布于2024年3月9日 21:20
阅读数 242

#include <iostream>
using namespace std;

int main()
{
	string s;
	while (cin >> s)
	{
		string::iterator it;
		for (it = s.begin(); it < s.end(); it++)
		{
			if (*it >= 'a' && *it <= 'z')
			{
				*it += 3;
				if (*it > 'z')
				{
					*it %= 'z';
					*it += 'a' - 1;
				}
			}
			if (*it >= 'A' && *it <= 'Z')
			{
				*it += 3;
				if (*it > 'Z')
				{
					*it %= 'Z';
					*it += 'A' - 1;
				}
			}
		}
		cout << s << " ";
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发