首页 > 代码库 > 字符变换

字符变换

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string str;
	getline(cin, str);
	for (int i =0; i < str.size(); ++i)
	{
		if (str[i] <= 'U' && str[i] >= 'A')
		{
			str[i] ='a' + str[i] - 'A' + 5;
		}
		else if (str[i] <= 'Z' && str[i] >= 'V')
		{
			str[i] ='a' + (str[i] - 'A'  -21)%26;
		}
	}
	cout<<str<<endl;
	return 0;
}

字符变换