HDUOJ-------The Hardest Problem Ever
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<iostream>
2 #include<cstring>
3 #include<cstdlib>
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<strlen(a);i++)
18 {
19 if(a[i]>='A'&&a[i]<='Z')
20 printf("%c",str[a[i]-'A']);
21 else
22 printf("%c",a[i]);
23 }
24 puts("");
25 }
26 a[0]=0;
27 getchar();
28 }
29 return 0;
30 }
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 使用 Log4j2 + SLF4j 打造日志系统的全方位教程
- 树莓派4的操作系统安装烧录、设置SSH、WIFI、VNC及备份
- C# dotnet 使用 startIndex 提升 IndexOf 的性能
- vscode .vue文件格式配置 使其与webstorm设置一致
- Go 语言学习之 slice
- koa2实现微信公众号关注自动回复消息
- 两个字数字字符串求和
- 设计模式(二):Android 源码中的工厂模式
- MoveIt!之ROS1Melodic版本发布(MoveItCpp教程)
- 机器学习第1天:线性回归(代码篇)
- PHP二分查找
- OnClick 的另一种书写
- JVM系列之:JIT中的Virtual Call
- 速读原著-UnixLinux基础(五)
- Celery在Django中的简单应用