南邮 OJ 1532 B ? Cryptoquote

B ? Cryptoquote

时间限制(普通/Java) :  1000 MS/ 3000 MS          运行内存限制 : 65536 KByte
总提交 : 52            测试通过 : 25 

比赛描述

cryptoquote is a simple encoded message where one letter is simply replaced by anotherthroughout the message. For example:

Encoded: HPC PJVYMIY

Decoded: ACM CONTEST

In the example above, H=AP=CC=MJ=OV=NY=TM=E and I=S. For this problem, you willdecode messages.



输入

The first line of input contains a single integer N, (1 £ £ 1000) which is the number of data sets thatfollow. Each data set consists of two lines of input. The first line is the encoded message. Thesecond line is a 26 character string of upper case letters giving the character mapping for each letterof the alphabet: the first character gives the mapping for A, the second for and so on. Only uppercase letters will be used. Spaces may appear in the encoded message, and should be preserved inthe output string.

输出

For each data set, you should generate one line of output with the following values: The data setnumber as a decimal integer (start counting at one), a space and the decoded message.

样例输入

2
HPC PJVYMIY
BLMRGJIASOPZEFDCKWYHUNXQTV
FDY GAI BG UKMY
KIMHOTSQYRLCUZPAGWJNBVDXEF

样例输出

1 ACM CONTEST
2 THE SKY IS BLUE

提示

undefined

题目来源

ACM ICPC Greater New York Region 2008




#include<iostream>
#include<string>
using namespace std;

int main(){
	string s,s1;
	int n,i,len,j;
	cin>>n;
	getchar();
	for(i=1; i<=n; i++){
		getline(cin,s1);
		getline(cin,s);
		len = (int)s1.length();
		for(j=0; j<len; j++){
			if(s1[j]>='A' && s1[j]<='Z'){
				s1[j] = s[s1[j]-'A'];
			}
		}
		cout<<i<<' '<<s1<<endl;
	}
}



你可能感兴趣的:(ACM,B,南邮OJ,Cryptoquote)