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:

  1. Start line - A single line, "START"
  2. Cipher message - A single line containing from one to two hundred characters, inclusive, comprising a single message from Caesar
  3. 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 【题意】:

你是Caesar军队的一个分队长。你的工作是破译Caesar送来的信息并汇报给你的上级。
密码很简单,每一个字母对应着一个明文,你将明文向右五步来得到安全的信息。(比如,假如那个字母是‘A’,密文就是‘F’)当你将Caesar的信息中找出明文后,你要反过来做:
加密文本
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 
明文文本 
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 
密文中只有字母被切换了,非字母的字符应该保持不变,所有的字母都是大写的。

这个问题的输入包括一系列(非空)最多100个数据。每一个数据的格式会按照以下格式,并且在不同组数据间不会有空行分隔。所有的字符都是大写的。
一个单独的测试数据包括三个部分:
1. 开始行:单独的一行“START” 。
2. 加密的信息:单独的一行,由1~200个字符组成来自Caesar的一行信息。
3. 结束行:单独的一行“END” 。
最后一组测试数据结束会跟着单独的一行“ENDOFINPUT”。

【代码】:

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
#pragma comment(linker, "/STACK:102400000,102400000")
#define Abs(x) ((x^(x >> 31))-(x>>31))
#define Swap(a,b) (a^=b,b^=a,a^=b)
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define EPS 1e-8
#define MOD 1000000007
#define max_ 10005
#define maxn 200002 using namespace std;
char a[];
int main()
{ while(gets(a))
{
if(!strcmp(a,"ENDOFINPUT")) break;
else if(!strcmp(a,"START")||!strcmp(a,"END")) continue;
for(int i=;a[i];i++)
{
if(isalpha(a[i]))
{
a[i]=((a[i]-'A')+-)%+'A';
}
}
puts(a);
}
return ;
}
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
#pragma comment(linker, "/STACK:102400000,102400000")
#define Abs(x) ((x^(x >> 31))-(x>>31))
#define Swap(a,b) (a^=b,b^=a,a^=b)
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define EPS 1e-8
#define MOD 1000000007
#define max_ 10005
#define maxn 200002 using namespace std;
char a[],b[];
int main()
{
char s[]={"VWXYZABCDEFGHIJKLMNOPQRSTU"};
while(gets(a))
{
int k=;
if(!strcmp(a,"ENDOFINPUT")) break;
if(strcmp(a,"START")!=&&strcmp(a,"END")!=)
{
for(int i=;a[i];i++)
{
if(isalpha(a[i]))
{
printf("%c",s[a[i]-'A']);
}
else
{
printf("%c",a[i]);
}
}
printf("\n");
}
}
return ;
}

常量字符数组妙用

POJ 1298 The Hardest Problem Ever【字符串】的更多相关文章

  1. poj 1298 The Hardest Problem Ever

    题目链接:http://poj.org/problem?id=1298 题目大意:按照所给的顺序要求将输入的字符串进行排列. #include <iostream> #include &l ...

  2. 1298 The Hardest Problem Ever

    题目链接:http://poj.org/problem?id=1298 思路分析:水题,字符偏移求解,注意字符串输入问题即可. 代码如下: #include <iostream> #inc ...

  3. The Hardest Problem Ever(字符串)

    The Hardest Problem Ever Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24039   Accept ...

  4. (字符串 枚举)The Hardest Problem Ever hdu1048

    The Hardest Problem Ever 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1048 Time Limit: 2000/1000 MS ...

  5. HDUOJ-------The Hardest Problem Ever

    The Hardest Problem Ever Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  6. hdu_1048_The Hardest Problem Ever_201311052052

    The Hardest Problem Ever Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  7. HDU1048The Hardest Problem Ever

    The Hardest Problem Ever Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & ...

  8. POJ.3468 A Simple Problem with Integers(线段树 区间更新 区间查询)

    POJ.3468 A Simple Problem with Integers(线段树 区间更新 区间查询) 题意分析 注意一下懒惰标记,数据部分和更新时的数字都要是long long ,别的没什么大 ...

  9. poj 1298(水题)

    The Hardest Problem Ever Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24241   Accept ...

随机推荐

  1. 《Cracking the Coding Interview》——第6章:智力题——题目6

    2014-03-20 01:14 题目:有100栈灯,一开始都关着.如果你按照n从1~100的顺序,每次都掰一下n的倍数的开关(开->关,关->开),那么到最后有多少灯是亮的? 解法:这个 ...

  2. linux_shell基础-变量、数组、运算符

    #!/bin/bash# echo 'hello world'# name='http://www.baidu.com'# for file in $(ls ./); do# echo "t ...

  3. 孤荷凌寒自学python第二十一天初识python的类

    孤荷凌寒自学python第二十一天初识python的类 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 类是面向对象的编程语言非常重要的概念. 编程语言的进化史中从顺序编程到结构化编程,最后才 ...

  4. windows auto activate

    目前所支持的windows镜像都是未激活状态,未激活状态下很多功能无法使用. 以后将要实现的功能是,windows虚机启动后,网络正常后能与KMS服务器通信,自动激活key 目前想到两种办法: 1.b ...

  5. __PRETTY_FUNCTION__,__func__,__FUNCTION__

    今天在看苹果的官方demo的时候,发现这个打印调用方法的参数,很是好奇,遂bing了一番. NSLog(@"----------------%s",__PRETTY_FUNCTIO ...

  6. FormsAuthentication类

    理解代码: string cookieName = FormsAuthentication.FormsCookieName; FormsAuthentication类说明: // 摘要: // 为 W ...

  7. nagios服务端安装

    系统环境:操作系统:CentOS-5.7 x86_64Apache版本: Apache-2.2.22Nagios版本: nagios-3.3.1GD库: gd-2.0.33 2.安装前准备:2.1.安 ...

  8. asp+access win2008php+mysql /dedecms 配置总结

    1.  IIS 应用池  高级设置  启用32位应用程序:True 2. c盘window/Temp user 应该有管理权限           如果不行 creator owner 给予修改权限 ...

  9. SQL Server 重新编译存储过程的方式有三种

    SQL Server 中,强制重新编译存储过程的方式有三种: sp_recompile 系统存储过程强制在下次执行存储过程时对其重新编译.具体方法是:从过程缓存中删除现有计划,强制在下次运行该过程时创 ...

  10. 【bzoj1044】[HAOI2008]木棍分割 二分+dp

    题目描述 有n根木棍, 第i根木棍的长度为Li,n根木棍依次连结了一起, 总共有n-1个连接处. 现在允许你最多砍断m个连接处, 砍完后n根木棍被分成了很多段,要求满足总长度最大的一段长度最小, 并且 ...