hdu 1328 IBM Minus One

来源:互联网 发布:云计算和超级计算机 编辑:程序博客网 时间:2024/05/01 01:16

题意:字符加1,26个字母循环。



#include<iostream>#include<string>using namespace std;int main(){    int n;    string str;    cin>>n;    for(int k=1;k<=n;k++){        cin>>str;        cout<<"String #"<<k<<endl;        for(int i=0;i<str.length();i++){            if(str[i]<'Z'){                str[i]++;            }else{                str[i]='A';            }        }        cout<<str<<endl<<endl;    }    return 0;}





IBM Minus One

IBM减少一个
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4501    Accepted Submission(s): 2361


Problem Description
You may have heard of the book '2001 - A Space Odyssey' by Arthur C. 
你可能听说过C写的的“2001太空漫游”。
Clarke, or the film of the same name by Stanley Kubrick. In it a spaceship is sent from Earth to Saturn. 
克拉克,或者与电影同名的斯坦利·库布里克。用宇宙飞船从地球飞到土星。
The crew is put into stasis for the long flight, only two men are awake, and the ship is controlled by the intelligent computer HAL. 
在长度飞行中,大部分船员进入休眠状态,只有两人清醒,这艘船是由智能电脑HAL控制。
But during the flight HAL is acting more and more strangely, and even starts to kill the crew on board. 
但在班机飞行途中,HAL变的非常古怪,甚至开始杀害船员。
We don't tell you how the story ends, in case you want to read the book for yourself :-)
我们不告诉你故事的结局,除非你读这本书。
After the movie was released and became very popular, there was some discussion as to what the name 'HAL' actually meant. 
这部电影被播放后,变得非常受欢迎,有一些人甚至讨论名称“哈尔”实际上意味着什么。
Some thought that it might be an abbreviation for 'Heuristic ALgorithm'. 
一些人认为它可能是一个缩写的启发式算法。
But the most popular explanation is the following: 
但最流行的解释如下:
if you replace every letter in the word HAL by its successor in the alphabet, you get ... IBM.
如果你替换单词里的每个字母,都符合hal的拼写,那么你有可能  .......  IBM。
Perhaps there are even more acronyms related in this strange way! You are to write a program that may help to find this out.
也许有更多的缩写词相关的这个奇怪的方式!你要编写一个程序,可以发现这一点。

Input
The input starts with the integer n on a line by itself - this is the number of strings to follow. 
输入的第一行是一个整数n,表示测试事件的个数。
The following n lines each contain one string of at most 50 upper-case letters.
 接下来有n行输入,每一行的长度最大是50,且是大写字母。

Output
For each string in the input, first output the number of the string, as shown in the sample output. 
对于每一行输入的字符串,首先输出字符串的序号,所示的示例输出。
The print the string start is derived from the input string by replacing every time by the following letter in the alphabet, and replacing 'Z' by 'A'.
输出的字符串是与之匹配的字符+1,在“A”到“Z”字符之间循环。
Print a blank line after each test case.
 每一个输出事件后面都有一行空白行。

Sample Input
2HALSWERC
 

Sample Output
String #1IBMString #2TXFSD
 

Source
Southwestern Europe 1997, Practice 

0 0
原创粉丝点击