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 :-)
|
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'.
|
Sample Input 2 HAL SWERC
|
Sample Output String #1 IBM String #2 TXFSD
|
Source Southwestern Europe 1997, Practice
|
Recommend Ignatius.L |
翻译版
|
输入 输入以行上的整数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");
}
}