題目描述
在大學裏,很多單詞都是一詞多義,偶爾在文章裏還要用引申義。這困擾Redraiment很長的時間。
他開始蒐集那些單詞的所有意義。他發現了一些規律,例如
“a”能用“e”來代替, “c”能用“f”來代替……
現在他給出了字母的替換規則,如下所示,A被E替換,B被C替換,依次類推。
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
E C F A J K L B D G H I V W Z Y M N O P Q R S T U X
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
e r w q t y g h b n u i o p s j k d l f a z x c v m
輸入要求
本題包括多組測試數據。 每組測試數據爲一行:爲僅由字母和空格組成的字符串(空格不變)。 輸入以單行“#”結束。
輸出要求
對應每組測試數據,替換後輸出它的引申義。
假如輸入
Ilttabaje zaujljg
#
應當輸出
Different meaning
#include<iostream>
#include<algorithm>
#include <vector>
#include<string.h>
#include<ctype.h>
using namespace std;
void fun();
char turn(char c)
{
char result;
if(c=='A')result='E';
if(c=='B')result='C';
if(c=='C')result='F';
if(c=='D')result='A';
if(c=='E')result='J';
if(c=='F')result='K';
if(c=='G')result='L';
if(c=='H')result='B';
if(c=='I')result='D';
if(c=='J')result='G';
if(c=='K')result='H';
if(c=='L')result='I';
if(c=='M')result='V';
if(c=='N')result='W';
if(c=='O')result='Z';
if(c=='P')result='Y';
if(c=='Q')result='M';
if(c=='R')result='N';
if(c=='S')result='O';
if(c=='T')result='P';
if(c=='U')result='Q';
if(c=='V')result='R';
if(c=='W')result='S';
if(c=='X')result='T';
if(c=='Y')result='U';
if(c=='Z')result='X';
if(c=='a')result='e';
if(c=='b')result='r';
if(c=='c')result='w';
if(c=='d')result='q';
if(c=='e')result='t';
if(c=='f')result='y';
if(c=='g')result='g';
if(c=='h')result='h';
if(c=='i')result='b';
if(c=='j')result='n';
if(c=='k')result='u';
if(c=='l')result='i';
if(c=='m')result='o';
if(c=='n')result='p';
if(c=='o')result='s';
if(c=='p')result='j';
if(c=='q')result='k';
if(c=='r')result='d';
if(c=='s')result='l';
if(c=='t')result='f';
if(c=='u')result='a';
if(c=='v')result='z';
if(c=='w')result='x';
if(c=='x')result='c';
if(c=='y')result='v';
if(c=='z')result='m';
return result;
}
int main()
{
fun();
return 0;
}
void fun()
{
char str[1001],str0,str1;
int arr[1001];
int i;
while(gets(str))
{
if(str[0]=='#')
break;
for(i=0;i<strlen(str);i++)
{
if(str[i]==' ')
cout<<' ';
else
cout<<turn(str[i]);
}
cout<<endl;
}
}