Message encryption

Message encryption

Encrypt the text. The encryption rule is that for each character, if it is a letter, it is transformed into the fourth letter of its corresponding (cyclic alphabetical order, that is, A immediately after Z). For example, A becomes E, a becomes e, W becomes A, X becomes B, Y becomes C, and Z becomes D. If it is not a letter, no conversion is performed.

Enter a line of characters.
Output the corresponding password.
Please pay attention to the line ending output.

enter

China!

Output

Glmre!
//电文加密
#include <iostream>
using namespace std;
int main(void) 
{
    
    
    char c;
    while((c=getchar())!='\n')		//遇到换行符时整体输出
    {
    
    
        if(c>='A'&&c<='V'||c>='a'&&c<='v')
        c=c+4;		//其后的第4个字母
        else if(c>='W'&&c<='Z'||c>='w'&&c<='z')
        c=c+4-26;
        cout<<c;
    }
    return 0;
}

Guess you like

Origin blog.csdn.net/qq_45830912/article/details/114094161