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 ...
随机推荐
- linux c语言连接mysql
ubuntu下使用apt-get安装mysql: sudo apt-get install mysql-server sudo apt-get install mysql-client sudo ap ...
- c 指针 及其位运算循环移动拔河比赛问题代码
week_2_day1_7.7 周一//用字符数组 来实现 字母大小写转换#include<stdio.h>void desc( char *a ,int n){ char *i ...
- ERS卫星
http://www.esa.int/Our_Activities/Operations/ERS-2 ERS-2 ROLE Earth observation (EO) LAUNCH DATE 21 ...
- 使用plist的好处
首先:帮助节省内存.OpenGL ES纹理要求宽和高都是2的n次幂的倍数.我们可以考虑将小的图片拼大图片,然后统一加载. 其次:提高渲染速度.OpenGL ES要求切换的纹理越少越好,将图片拼成大图 ...
- mysql utf8 中文
#!/usr/bin/perl use DBI; use Encode; $user="root"; $passwd="1234567"; $dbh=" ...
- 【玩转Ubuntu】02. Ubuntu上搭建Android开发环境
一. 基本环境搭建 1.官网http://developer.android.com/sdk/index.html ,下载adt-bundle-linux-x86_64-20130729.zip 2. ...
- 改动分区后,导致linux上不了
/*************************** *Author : 林旭东 *problem:基于分区改动出现的问题(1) *calender: 15/07/10 ******** ...
- 【转】HtmlAgilityPack 之 HtmlNode类
[转]HtmlAgilityPack 之 HtmlNode类 HtmlAgilityPack中的HtmlNode类与XmlNode类差不多,提供的功能也大同小异.下面来看看该类提供功能. 一.静态属性 ...
- T-SQL查询:语句执行顺序
读书笔记:<Microsoft SQL Server 2008技术内幕:T-SQL查询> =============== T-SQL查询的执行顺序 =============== === ...
- OC中对象元素的引用计数 自动释放池的相关概念
OC中数组对象在是如何处理对象元素的引用计数问题的,同时介绍一下自动释放池的相关概念 一.数组对象是如何处理对象元素的引用计数问题[objc] view plaincopy 1. // 2. / ...