POJ 1298 The most difficult question in history--Caesar code

Source: Internet
Author: User

The hardest problem in history
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 24958 Accepted: 13565

Description

Julian Caesar lives in an age of danger and intrigue, and the hardest of all is to survive. So he invented one of the earliest cipher systems for the army's message delivery.
Suppose you are an officer in the Caesar Corps who needs to decipher the message sent by Caesar and provide it to your general. Message encryption is done by replacing each letter in the original message with the 5th letter of the letter (for example: Each letter A in the original message is replaced with the letter F). And you want to get the message in the original, which is to reverse the process.

Password Letter: 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
Original text mother: 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

Note: Only letters are replaced, other non-alphabetic characters are not changed, and all letters in the original message are capitalized.

Input

No more than 100 datasets, no blank rows between each dataset, and each dataset consists of 3 parts:
    1. Start line: Start
    2. Password message: A line consisting of 1 to 200 characters representing a message from Caesar.
    3. Ending line: End

After the last dataset, there is another line: Endofinput

Output

One row for each dataset is the original message of Caesar.

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

As a result of learning Network security course, this topic has done experiments before, is a Caesar password problem, that is, the character moved forward 5 times, pay attention to modulo 26

#include <stdio.h> #include <string.h> #include <algorithm>using namespace Std;char S[105];char t[16] ; int main () {int i,j;while (scanf ("%s", T)) {if (strcmp (t, "endofinput") ==0) Break;getchar (); Gets (s); for (i=0;s[i]!= ' ; i++) {if (s[i]>= ' a ' &&s[i]<= ' Z ') s[i]= (s[i]-' a ' +26-5)%26+ ' a ';} scanf ("%s", T);p UTS (s);} return 0;}


POJ 1298 The most difficult question in history--Caesar code

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.