博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDUOJ-------The Hardest Problem Ever
阅读量:5889 次
发布时间:2019-06-19

本文共 3034 字,大约阅读时间需要 10 分钟。

The Hardest Problem Ever

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 13035    Accepted Submission(s): 5905

Problem 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
 

 

Source
 
此题为简单的字符串处理问题....
但是要注意数组开大点....1000足矣;
1 #include
2 #include
3 #include
4 char str[27]="VWXYZABCDEFGHIJKLMNOPQRSTU"; 5 char a[120]; 6 int main() 7 { 8 int i; 9 // freopen("test.in","r",stdin);10 // freopen("test.out","w",stdout);11 while(scanf("%[^\n]",a)!=EOF)12 {13 if(strcmp("ENDOFINPUT",a)==0)14 break;15 if(strcmp("START",a)!=0&&strcmp("END",a)!=0)16 {17 for(i=0;i
='A'&&a[i]<='Z')20 printf("%c",str[a[i]-'A']); 21 else22 printf("%c",a[i]);23 }24 puts("");25 }26 a[0]=0;27 getchar();28 }29 return 0;30 }
View Code

 

 

 

转载地址:http://btysx.baihongyu.com/

你可能感兴趣的文章
在Fedora8上安装MySQL5.0.45的过程
查看>>
TCP长连接与短连接的区别
查看>>
设计模式之命令模式
查看>>
android 测试 mondey
查看>>
Spring AOP项目应用——方法入参校验 & 日志横切
查看>>
TestNG 六 测试结果
查看>>
用Fiddler或Charles进行mock数据搭建测试环境
查看>>
使用REST-Assured对API接口进行自动化测试
查看>>
GitHub发布史上最大更新,年度报告出炉!
查看>>
王潮歌跨界指导HUAWEI P20系列发布会 颠覆传统 眼界大开!
查看>>
王高飞:微博已收购一直播 明年一季度重点是功能与流量打通
查看>>
趣头条发行区间7至9美元 预计9月14日美国上市
查看>>
新北市长侯友宜:两岸交流应从隔壁最亲近的人开始
查看>>
全面屏的Nokia X即将上线,不到2000元的信仰你要充值吗?
查看>>
HTML5音频audio属性
查看>>
ES6学习
查看>>
Centos7搭建Django环境
查看>>
序列化一个Intent
查看>>
JavaScript数据类型及语言基础--ife
查看>>
进阶 Nginx 高手必须跨越的 5 座大山
查看>>