The Hardest Problem Ever(字符串)
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 24039 | Accepted: 13143 |
Description
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
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
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
题解:字符串替换;
代码:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=;
char plain[MAXN],str[MAXN];
int main(){
strcpy(plain,"VWXYZABCDEFGHIJKLMNOPQRSTU");
while(true){
cin.getline(str,MAXN);
if(!strcmp(str,"ENDOFINPUT"))break;
else if(!strcmp(str,"START")||!strcmp(str,"END"))continue;
else for(int i=;str[i];i++){
if(isalpha(str[i]))str[i]=plain[str[i]-'A'];
}
printf("%s\n",str);
}
return ;
}
The Hardest Problem Ever(字符串)的更多相关文章
- (字符串 枚举)The Hardest Problem Ever hdu1048
The Hardest Problem Ever 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1048 Time Limit: 2000/1000 MS ...
- HDUOJ-------The Hardest Problem Ever
The Hardest Problem Ever Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- hdu_1048_The Hardest Problem Ever_201311052052
The Hardest Problem Ever Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- HDU1048The Hardest Problem Ever
The Hardest Problem Ever Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
- POJ 1298 The Hardest Problem Ever【字符串】
Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was ke ...
- Poj1298_The Hardest Problem Ever(水题)
一.Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar eve ...
- poj1298 The Hardest Problem Ever 简单题
链接:http://poj.org/problem?id=1298&lang=default&change=true 简单的入门题目也有这么强悍的技巧啊!! 书上面的代码: 很厉害有没 ...
- HDOJ 1048 The Hardest Problem Ever(加密解密类)
Problem Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caes ...
- C - The Hardest Problem Ever
Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever ...
随机推荐
- Linux08--Shell程序设计03 shell script
第一个Shell脚本——HelloWorld [root@localhost ~]# vi sh01.sh #!/bin/bash #!表明使用哪种shell # this is my first s ...
- Linux01--文件管理,常用命令 权限管理
一.Ø文件系统 1.Linux文件系统特点 • Linux文件系统为单根的树状结构 •文件系统根为”/” •文件名大小写敏感,除了”/”都是可用字符文件名以”.”开始的为隐藏文件 •文件路径使 ...
- NetworkManager——Linux强大的网络管理工具
NetworkManager服务:NetworkManager - Linux Networking made Easy NetworkManager简介:NetworkManager由一个管理系统网 ...
- C#dll版本号默认生成规则
原文:C#dll版本号默认生成规则 1.版本号自动生成方法 只需把 AssemblyInfo.cs文件中的[assembly: AssemblyVersion("1.0.0.0") ...
- java线程管理
java线程管理 参见: http://harmony.apache.org/subcomponents/drlvm/TM.html 1. 修订历史 2. 关于本文档 2.1. 目的 2.2. 面向的 ...
- poj1504--求两个数的反转数的和的反转数
题意:给定4321 5678,结果再反转(1234+8756) 一开始以为是poj1503一样,就稀里糊涂的敲代码,实际上有不同 如题:先求1234 + 8765 ------------------ ...
- action中实现对批量文件上传的封装
如今,文件(尤其是图片)上传,在前后台的应用相当普遍,上传头像.共享资料等已成为最基本应用.我们很希望通过一个万能的封装方法来实现一劳永逸的效果. 接下来,就来为大家介绍具体实现. 首先,我们需要一个 ...
- 将Dictionary序列化为json数据 、json数据反序列化为Dictionary
需要引用System.Web.Extensions dll类库 /// <summary> /// 将json数据反序列化为Dictionary /// </summary> ...
- Mina入门:mina版之HelloWorld
一,前言: 在完成上篇文章<Mina入门:Java NIO框架Mina.Netty.Grizzly简介与对比>之后,我们现在可以正式切入Mina入门学习了. 二,搭建项目结构与解决项目依赖 ...
- JS onkeydown控制HTML Input 只录入浮点数值
// -1) return false; return index == 0 } keychar = String.fromCharCode(keynum) var newVal = oriVal.s ...