zsc_寒假训练 5

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 was so incredibly sound, that 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 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 would 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 should 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, inclusive, 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 IFSLJWTZX YMFS MJ
END
ENDOFINPUT

Sample Output

IN WAR, EVENTS OF IMPORTANCE ARE THE RESULT OF TRIVIAL CAUSES
I WOULD RATHER BE FIRST IN A LITTLE IBERIAN VILLAGE THAN SECOND IN ROME
DANGER KNOWS FULL WELL THAT CAESAR IS MORE DANGEROUS THAN HE

 1 #include<iostream>
 2 #include<cstring>
 3 #include<cstdio>
 4 #include<algorithm>
 5 using namespace std;
 6 int main()
 7 {
 8 #ifdef CDZSC_OFFLINE
 9     freopen("in.txt","r",stdin);
10     freopen("out.txt","w",stdout);
11 #endif
12     char b[]="VWXYZABCDEFGHIJKLMNOPQRSTU";
13     char *a[]={"START","END","ENDOFINPUT"};
14     char s[15],x[250];
15     while(scanf("%s",s))
16     {
17         getchar();
18         if(strcmp(a[0],s)==0)
19         {
20             while(gets(x))
21             {
22                 if(strcmp(a[1],x)==0)
23                 {
24                     break;
25                 }
26                 else
27                 {
28                     int len=strlen(x);
29                     for(int i=0;i<len;i++)
30                     {
31                         if(x[i]>=‘A‘&&x[i]<=‘Z‘)
32                         {
33                             putchar(b[x[i]-‘A‘]);
34                         }
35                         else
36                         {
37                             if(x[i]>=‘a‘&&x[i]<=‘z‘)
38                             {
39                                 putchar(b[x[i]-‘a‘]);
40                             }
41                             else
42                             {
43                                 putchar(x[i]);
44                             }
45                         }
46                     }
47                     printf("\n");
48                 }
49
50             }
51         }
52         if(strcmp(a[2],s)==0)
53         {
54             return 0;
55         }
56     }
57 }

时间: 2024-12-29 11:18:52

zsc_寒假训练 5的相关文章

zsc_寒假训练 8

Description Ignatius was born in a leap year, so he want to know when he could hold his birthday party. Can you tell him? Given a positive integers Y which indicate the start year, and a positive integer N, your task is to tell the Nth leap year from

zsc_寒假训练 7

Description Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them. Input The input contains several test cases. The first line of the input is a s

zsc_寒假训练 6

Description An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u inches every minute, but then has to rest a minute before climbing again. During the rest, it slips down d inches. The process of climbing and resting

zsc_寒假训练 4

Description These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fairly difficulty to do such a thing. Of course, I got it after many waking nights. Give you some integers, your task is to sort these number ascend

zsc_寒假训练 3

Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean. The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat

zsc_寒假训练 9

Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course. There are 5 problems i

常州大学新生寒假训练会试 题解

[题目链接] A - 添加逗号 注意是从后往前三个三个加逗号,最前面不允许有逗号 #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; char s[maxn]; char ans[maxn]; int sz; int main() { scanf("%s", s); int len = strlen(s); sz = 0; int t = 0; for(int i = len -

FZU ICPC 2020 寒假训练 4 —— 模拟(一)

P1042 乒乓球 题目背景 国际乒联现在主席沙拉拉自从上任以来就立志于推行一系列改革,以推动乒乓球运动在全球的普及.其中11分制改革引起了很大的争议,有一部分球员因为无法适应新规则只能选择退役.华华就是其中一位,他退役之后走上了乒乓球研究工作,意图弄明白11分制和21分制对选手的不同影响.在开展他的研究之前,他首先需要对他多年比赛的统计数据进行一些分析,所以需要你的帮忙. 题目描述 华华通过以下方式进行分析,首先将比赛每个球的胜负列成一张表,然后分别计算在11分制和21分制下,双方的比赛结果(

FJUT2017寒假训练二题解

A题 题意:让你找出唯一的一个四位数,满足对话时的要求. 思路:因为是4位数,可以直接从1000-9999遍历一遍,判断是否有唯一的数能满足所有条件,如果不是唯一的或者没有满足条件的数就输出Not sure.特别丑的代码附上... 1 #include<stdio.h> 2 int a[10000],b[10000],c[10000]; 3 int main() 4 { 5 int n; 6 while(~scanf("%d",&n)) 7 { 8 if(n==0)