南邮 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;
	}
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值