C-the hardest problem ever

Source: Internet
Author: User

Description

Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher is so incredibly sound, and that's no one could figure it out without knowing how it worked.
You are a sub captain of Caesar ' s army. It is your job to decipher the messages sent by Caesar and provide to your general. The code is simple. For each of the plaintext message, you shift it five places to the right to create the secure message (i.e., if the L Etter is ' A ', the cipher text would was ' F '). Since you is creating plain text out of Caesar ' s messages, you'll do the opposite:
Cipher text 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
Plain text 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
Only letters is shifted in this cipher. Any non-alphabetical character should remain the same, and all alphabetical characters would be a upper case.

Input

Input to this problem would consist of a (Non-empty) series of up to data sets. Each data set is formatted according to the following description, and there would be no blank lines separating data s Ets. All characters would be uppercase.
A Single Data set have 3 components:
    1. Start Line-a single line, "Start"
    2. Cipher message-a single line containing from one to the other hundred characters, inclusive, comprising A single message from Caesar
    3. End Line-a single line, "End"
Following the final data set would be a, "endofinput".

Output

For each data set, there'll is exactly one line of output. The original message by 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
Decode, move left five bits

#include <iostream>#include<string.h>#include<string>using namespacestd;intMain () {stringb;  while(cin>>a) {        if(a=="Endofinput") Break; if(a=="START"){            stringC; Chars[205]; intp=0;  while(cin>>B) {                if(c=="END") Break; intN; N=c.length ();  for(intI=0; i<n;i++){                    if(c[i]>='A'&&c[i]<='Z'){                        if(c[i]-5<'A') c[i]=c[i]-4+'Z'-'A'; Elsec[i]-=5; } S[p]=C[i]; P++; } S[p]=' '; P++; }             for(intI=0; i<p-1; i++) cout<<S[i]; cout<<Endl; }    }    //System ("pause");    return 0;}

Input/output format!

C-the hardest problem ever

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.