CDZSC_2015寒假新人(1)——基础 E

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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
#ifdef CDZSC_OFFLINE
    freopen("in.txt","r",stdin);
#endif
    char str[15],s[1024];
    char a[27]="VWXYZABCDEFGHIJKLMNOPQRSTU";
    int len,i;
    while(scanf("%s",str))
    {
        if(strcmp(str,"ENDOFINPUT")==0)
        {
            break;
        }
        getchar();
        cin.getline(s,1024);
        scanf("%s",str);
        len=strlen(s);
        for(i=0; i<len; i++)
        {
            if(s[i]>=‘A‘&&s[i]<=‘Z‘)
            {
                printf("%c",a[s[i]-‘A‘]);
            }
            else
            {
                printf("%c",s[i]);
            }
        }
        printf("\n");
    }
    return 0;
}

时间: 2024-10-07 11:33:45

CDZSC_2015寒假新人(1)——基础 E的相关文章

CDZSC_2015寒假新人(1)——基础 I

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

CDZSC_2015寒假新人(1)——基础 B

Description The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor

CDZSC_2015寒假新人(1)——基础 D

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

CDZSC_2015寒假新人(1)——基础 G

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

CDZSC_2015寒假新人(1)——基础 F

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

CDZSC_2015寒假新人(1)——基础 C

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

CDZSC_2015寒假新人(1)——基础 H

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 ye

CDZSC_2015寒假新人(2)——数学 - O

Description 当寒月还在读大一的时候,他在一本武林秘籍中(据后来考证,估计是计算机基础,狂汗-ing),发现了神奇的二进制数. 如果一个正整数m表示成二进制,它的位数为n(不包含前导0),寒月称它为一个n二进制数.所有的n二进制数中,1的总个数被称为n对应的月之数. 例如,3二进制数总共有4个,分别是4(100).5(101).6(110).7(111),他们中1的个数一共是1+2+2+3=8,所以3对应的月之数就是8. Input 给你一个整数T,表示输入数据的组数,接下来有T行,每

CDZSC_2015寒假新人(4)——搜索 A

Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and