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 ...
随机推荐
- 5款免费Windows远程连接Linux桌面软件(VNC客户端)
不论我们出于何种的用途目的,很多朋友有需要用到VNC链接Linux桌面环境,之前老左有分享过VNC Viewer绿色软件,昨天有朋友提出来使用之后登录远程桌面的界面.分辨率等有些色差.流畅程度 ...
- iOS UITableViewCell透明度 和 cell文字居中
1.创建UITableViewCell时,的模式用UITableViewCellStyleValue1时,透明度直接将UITableView的透明度设置以下就搞定拉,但是文字居中难以实现. 2.创建U ...
- 使用kd-tree加速k-means
0.目录 前置知识 思路介绍 详述 1 确定h的中心点 2 算法步骤 java实现 1.前置知识 本文内容基于<Accelerating exact k-means algorithms wit ...
- AndroidUI 视图动画-自定义动画效果 (Animation)
如果Android提供的四种动画 效果 和混合动画效果 不能够 满足需求的话,可以使用自定义动画效果 : 新建一个类CustomAnimation 使其继承自 android.view.animati ...
- windows开机启动nginx
1 .http://www.cuplayer.com/player/PlayerCode/Nginx/2014/0919/1577.html 2. http://www.cnblogs.com/xus ...
- Colorbox cannot load the image added by js
As we know, Colorbox is a wonderful js plugin. I came up against a head-banged problem in v1.5.6. Wh ...
- swift 用协议实现代理传值功能
1.功能简介 RootViewController中用个lable和一个按钮,点击按钮跳转到模态窗口.在模态窗口中有个TextField和一个按钮,输入文字点击关闭模态按钮后跳转到RootViewCo ...
- js生成随机数的方法实例总结 [收藏]
js生成随机数的方法实例总结 js生成随机数主要用到了内置的Math对象的random()方法.用法如:Math.random().它返回的是一个 0 ~ 1 之间的随机数.有了这么一个方法,那生成任 ...
- DIV以及图片水平垂直居中兼容多种浏览器
纯css完美地解决图片以及div垂直水平居中,兼容IE7.0.IE6.0.IE5.5.IE5.0.FF.Opera.Safari具体实现css 如下,感兴趣的朋友可以参考下哈 第一种:全CSS控制 ...
- mysql 基本使用
SQL分类 -------------------数据库------------ 创建数据库 create database xxx; 查询所有的数据库 show databases; 查询当前数据 ...