IBM Minus One (hdoj 1.2.7)

Problem Description

You may have heard of the book '2001 - A Space Odyssey' by Arthur C. 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. But during the flight HAL is acting more and more strangely, and even starts to kill the crew on board. 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.

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. The following n lines each contain one string of at most 50 upper-case letters.

 

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'.

Print a blank line after each test case.

 

Sample Input

2
HAL
SWERC

 

Sample Output

String #1
IBM

String #2
TXFSD

 

 

Source

Southwestern Europe 1997, Practice

 

Recommend

Ignatius.L

 

翻译版


你可能听说过Arthur C. Clarke的书“2001 - A Space Odyssey”,或者是Stanley Kubrick的同名电影。其中有一艘宇宙飞船从地球发送到土星。机组人员因长途飞行而陷入停滞状态,只有两名男子醒来,船只由智能电脑HAL控制。但是在飞行过程中,HAL的行动越来越奇怪,甚至开始杀死船上的船员。我们不会告诉你这个故事是如何结束的,如果你想为自己阅读这本书:-)

在电影上映并变得非常受欢迎之后,人们就“HAL”这个名字的实际含义进行了一些讨论。有些人认为它可能是“启发式算法”的缩写。但最流行的解释如下:如果你用字母表中的继承者替换单词HAL中的每个字母,你就得到...... IBM。

也许有更多的缩略词以这种奇怪的方式相关!你要编写一个可能有助于找到它的程序。

 

输入

输入以行上的整数n开始 - 这是要遵循的字符串数。以下n行每行包含一个最多50个大写字母的字符串。

 

产量

对于输入中的每个字符串,首先输出字符串的编号,如示例输出中所示。打印字符串start是从输入字符串派生的,每次都用字母表中的后续字母替换,并将'Z'替换为'A'。

在每个测试用例后打印一个空行。

 

样本输入

2 
HAL 
SWERC

 

样本输出

字符串#1 
IBM 

String#2 
TXFSD

 

 

资源

西南欧1997年,实践

 

推荐

Ignatius.L

这道题我用了map来存储字母的下一位直接用Mymap[ AT [ i ] ]就读取字母下一位

#include<iostream>
#include<stdio.h>
#include<map>
#include<string.h>
using namespace std; 
int main(){
	map<char,char>Mymap;
	Mymap['A']='B';
	Mymap['B']='C';
	Mymap['C']='D';
	Mymap['D']='E';
	Mymap['E']='F';
	Mymap['F']='G';
	Mymap['G']='H';
	Mymap['H']='I';
	Mymap['I']='J';
	Mymap['J']='K';
	Mymap['K']='L';
	Mymap['L']='M';
	Mymap['M']='N';
	Mymap['N']='O';
	Mymap['O']='P';
	Mymap['P']='Q';
	Mymap['Q']='R';
	Mymap['R']='S';
	Mymap['S']='T';
	Mymap['T']='U';
	Mymap['U']='V';
	Mymap['V']='W';
	Mymap['W']='X';
	Mymap['X']='Y';
	Mymap['Y']='Z';
	Mymap['Z']='A';
	int n,x=1;
	scanf("%d",&n);
	while(n--){
		char AT[999];
		scanf("%s",AT);
		int len=strlen(AT);
		printf("String #%d\n",x++);
		for(int i=0;i<len;i++){
			printf("%c",Mymap[AT[i]]);
		}
			printf("\n\n");	

	}
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值