Foreword:
21. Regardless of whether you can enter the retest or not, record the garbage code written on the road. I originally gnawed on "Algorithm Notes", but I felt too much to do it, so I changed it to the Kingway Computer Test Guide.
Title description:
In the process of information transmission, in order to prevent the information from being intercepted, it is often necessary to encrypt the information in a certain way. Although a simple encryption algorithm is not enough to completely prevent the information from being deciphered, it can still prevent the information from being easily identified. We give a simplest encryption method. For a given string, replace the letters from ay, AY with their successors, and replace z and Z with a and A, and you can get a simple Encrypted string.
Enter description
Read this line of strings, each string is less than 80 characters in length
Output description:
For each group of data, output the encrypted string of each line of string.
answer
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
using namespace std;
int main()
{
string str;
while (getline(cin,str)) {
for (int i = 0; i < str.length(); i++)
if ((str[i] >= 'a' && str[i] <= 'y') || (str[i] >= 'A' && str[i] <= 'Y'))
str[i] += 1;
else if (str[i] == 'z')
str[i] = 'a';
else if (str[i] == 'Z')
str[i] = 'A';
cout << str << endl;
}
return 0;
}