Topic 1127: Simple password

Source: Internet
Author: User

Title Description:

Julius Caesar once used a very simple password.
For each character in the clear text, it is replaced with the following 5 characters in the alphabet, which gives the ciphertext.
For example, the character a is replaced by F. The following is the correspondence between ciphertext and the characters in clear text.
Ciphertext
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Plaintext
V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
Your task is to decrypt the given ciphertext to get the plaintext.
You need to be aware that the letters that appear in the ciphertext are in uppercase letters. The ciphertext also includes non-alphabetic characters, which do not have to be decoded.

Input:

The test data in the input does not exceed 100 groups. Each group of data has the following form, and there are no blank lines between the test data for each group.
A set of test data consists of three parts:
1. Start line-one row, including the string "START"
2. Redaction-a line, give the ciphertext, the cipher is not empty, and the number of characters not exceeding 200
3. End line-one row, including the string "End"
There is a row after the last set of test data, including the string "Endofinput".

Output:

For each group of data, there is a row of output, the ciphertext corresponding to the plaintext.

Sample input:
Startns BFW, Jajsyx tk nrutwyfshj fwj ymj wjxzqy tk ywnanfq hfzxjxendstartn btzqi wfymjw GJ knwxy NS F qnyyqj NGJWNFS ANQQ Flj Ymfs xjhtsi NS wtrjendstartifsljw pstbx kzqq bjqq ymfy hfjxfw NX rtwj ifsljwtzx Ymfs mjendendofinput
Sample output:
In WAR, EVENTS of importance is the RESULT of TRIVIAL Causesi would rather be first in A LITTLE Iberian VILLAGE THAN SECO ND in Romedanger KNOWS full well, CAESAR is more dangerous THAN HE
Source:
2008 Beijing University founder Laboratory Computer Research The real problem of life test
Answering:

#include <iostream> #include <string> using namespace std;        int main () {string S;            while (Getline (cin,s)) {if (S.compare ("Endofinput") ==0) break;                else if (S.compare ("START") ==0) {string temp;                    if (Getline (cin,temp)) {int len=temp.size ();                        for (int i=0;i<len;i++) {if (temp[i]<= ' Z ' &&temp[i]>= ' A ')                            {if (temp[i]<= ' E ') temp[i]+=21;                        else temp[i]-=5;                    }}} if (Getline (cin,s), S.compare ("END") ==0) {                cout<<temp<<endl;    }}} return 0; }/****************************************problem:1127 User:carvin language:c++ result:accepted time:10 Ms memory:1520 kb****************************************************************/


Topic 1127: Simple password

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.