码迷,mamicode.com
首页 > 其他好文 > 详细

1316: University

时间:2014-11-15 17:14:03      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:c++

题目描述

在大学里,很多单词都是一词多义,偶尔在文章里还要用引申义。这困扰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;
	}
}



1316: University

标签:c++

原文地址:http://blog.csdn.net/a120705230/article/details/41146341

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!