Translated by Xiaoxiao (Hangzhou-1048)

Source: Internet
Author: User
/* The hardest problem evertime limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/others) total submission (s): 15859 accepted submission (s ): 7331 problem descriptionjulius Caesar lived in a time of danger and intrigger. the hardest situation Caesar ever faced was keeping himself alive. in order for him to keep ve, he decided to create one of the first ciphers. this cipher was so incret Dibly sound, that no one cocould 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 letter in a plaintext message, you shift it five places to the right to create the secure message (I. E ., if the letter is 'A', the cipher text wocould be 'F '). since you are Creating plain text out of Caesar's messages, you will do the opposite: cipher texta B c d e f g h I j k l m n o p q r s t u v w x y zplain textv 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 are shifted in this cipher. any non-alphabetical character shoshould remain the same, and all alphabetical characters will be upper case. inputinput to this problem will consist of a (non-empty) Series of up to 100 data sets. each data set will be formatted according to the following description, and there will be no blank lines separating data sets. all characters will be uppercase. A single data set has 3 components: start line-a single line, "Start" cipher message-a single line containing from one to two hundred characters, random Sive, comprising a single message from Caesar end l INE-a single line, "end" following the final data set will be a single line, "endofinput ". outputfor each data set, there will be exactly one line of output. this is the original message by Caesar. sample inputstartns BFW, jajsyx TK rjfwj ymj rjtk %%btzqi wfymjw GJ knwxy ns f %ngjwnfs anqqflj ymfs xjhtsi NS %pstbx kzqq bjqq ymfy hfjxfw NX rtwj ifsl1_tzx ymfs mjendendofinput sample outputin war, events of importance are the result of trivial causesi wocould rather be first in a little Iberian village than second in romedanger knows full well that Caesar is more dangerous than he */# include <stdio. h> // The misunderstanding in this question is that start and end have no practical significance, but start and end on the surface, # include <string. h> // In other words, they can be replaced with any string without affecting the output result. Int main () {char a [20] = {0}; char s [200] = {0}; while (gets (A) {If (strcmp (, "endofinput ")! = 1) break; gets (s); gets (a); int Len; Len = strlen (s); For (INT I = 0; I <Len; I ++) {If (s [I]> = 'A' & S [I] <= 'E') {s [I] + = 21 ;} else if (s [I] >='f' & S [I] <= 'Z') {s [I]-= 5 ;}} puts (s);} return 0 ;}
/*
The hardest problem ever
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 15859 accepted submission (s): 7331

Problem description
Julius Caesar lived in a time of danger and intrigger. the hardest situation Caesar ever faced was keeping himself alive. in order for him to keep ve, he decided to create one of the first ciphers. this cipher was so incredibly sound, that no one cocould 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 letter in a plaintext message, you shift it five places to the right to create the secure message (I. E ., if the letter is 'A', the cipher text wocould be 'F '). since you are creating plain text out of Caesar's messages, you will 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 are shifted in this cipher. Any non-alphabetical character shoshould remain the same, and all alphabetical characters will be upper case.
 
Input
Input to this problem will consist of a (non-empty) series of up to 100 data sets. each data set will be formatted according to the following description, and there will be no blank lines separating data sets. all characters will be uppercase.
A single data set has 3 components:
Start line-a single line, "start"
Cipher message-a single line containing from one to two hundred characters, sive Sive, comprising a single message from Caesar
End Line-a single line, "end"
Following the final data set will be a single line, "endofinput ".
 
Output
For each data set, there will be exactly one line of output. This is the original message by Caesar.
 
Sample Input
Start
Ns bfw, jajsyx TK nrutwyfshj fwj ymj wjxzqy TK ywnanfq hfzxjx
End
Start
N btzqi wfymjw GJ knwxy ns f qnyyqj ngjwnfs anqqflj ymfs xjhtsi NS wtrj
End
Start
Ifsljw pstbx kzqq bjqq ymfy hfjxfw NX rtwj ifsl1_tzx ymfs MJ
End
Endofinput
 
Sample output
In war, events of importance are the result of trivial causes
I wowould rather be first in a little Iberian village than second in Rome
Danger knows full well that Caesar is more dangerous than he
*/
# Include <stdio. h> // The misunderstanding in this question is that start and end are meaningless, but start and end are superficial,
# Include <string. h> // In other words, they can be replaced with any string without affecting the output result.
Int main ()
{
Char A [20] = {0 };
Char s [200] = {0 };
While (gets ()){

If (strcmp (a, "endofinput ")! = 1) break;
Gets (s );
Gets ();
Int Len;
Len = strlen (s );
For (INT I = 0; I <Len; I ++ ){
If (s [I]> = 'A' & S [I] <= 'E '){
S [I] + = 21;
}
Else
If (s [I]> = 'F' & S [I] <= 'Z '){
S [I]-= 5;
}
}
Puts (s );


} Return 0;
}

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.