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");
}
}