, o& b0 `. c7 `4 v& o- X; rDescription 0 z8 T% e/ c( Y/ @# CA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: $ f% O0 q* K7 N9 P* [5 P: ]( g; a8 _. p5 Z8 Q% m4 F
Encoded: HPC PJVYMIY 1 L( V* ~" \* g d
Decoded: ACM CONTEST2 r( _" h: k" w( b2 S" S
3 D, Z" l) D$ ]: Y" b$ q6 p; ^) e( w IIn the example above, H=A, P=C, C=M, J=O, V=N, Y=T, M=E and I=S. For this problem, you will decode messages. 8 G) u* z0 u) l/ |' P# M. h- S
% U0 z! m; ^8 o& ^( j8 X" h" F
& z( H# z( M! U1 n7 G
Input ; }/ o& ?& X6 v; O; N* u& q7 e* Q
The first line of input contains a single integer N,(1<=N<=1000) which is the number of data sets that follow. Each data set consists of two lines of input. The first line is the encoded message. The second line is a 26 character string of upper case letters giving the character mapping for each letter of the alphabet: the first character gives the mapping for A, the second for B and so on. Only upper case letters will be used. Spaces may appear in the encoded message, and should be preserved in the output string.- o: F* J8 d o6 R2 L% \
5 I; H T6 A# R$ k/ r5 Y- M W
4 V, t3 r) ~4 I. C E, I( r* |# w8 u6 k: F2 _2 O! u
Output ( ^# B3 V! X) j3 D; F; F' l& kFor each data set, you should generate one line of output with the following values: The data set number as a decimal integer (start counting at one), a space and the decoded message. 3 S7 u% O0 N2 }0 ]# R
/ |0 |* O0 O! t! M& s. ]8 G
4 Z. `( {% d0 c- Z/ R H
Sample Input # B7 o4 z* p# C, k- i2 1 P* k' Z0 ^% o* C$ hHPC PJVYMIY / E3 D% p* t$ P# x# W0 {, r2 }& ]BLMRGJIASOPZEFDCKWYHUNXQTV p# U+ K/ W) Q, f8 F
FDY GAI BG UKMY 4 U! N' S: P2 Y
KIMHOTSQYRLCUZPAGWJNBVDXEF : O. j' L4 ~# j4 c+ F) B7 g | 8 K4 g3 @4 k# Z5 q; E( x4 P! N# O. }$ S' h% @+ r0 i; v! t2 D
4 w; ^) w* Y: G' SSample Output 5 q% y5 T9 a5 _: ~1 ACM CONTEST ; [! a, Z. }. o4 g; J2 THE SKY IS BLUE* i3 N4 t" U y$ R! Q" J# ^+ D
) U, J1 V( M1 c( l $ }9 r& Q" ]# o- n0 X6 F$ N5 y0 A 6 \2 V* I% w5 s. |7 b我的代码是: 5 r' B0 j* ?% \6 Z#include<stdio.h>' H2 r. u1 L* H. u( h/ O( p: _4 ?
#include<string.h>0 [. z& c; W% Z3 Z' y: e5 L
int main(). o" u' {2 Y Y I) m* o
{2 N9 F) O* L9 L# x7 U- k# E
int N,i,j,k;, X: {+ J+ u' g
char c;1 z9 |1 |$ P* u3 W6 y, \ l* T
char code[1000];; {* _" O! r5 N# Y
char map[27]; 0 d) |2 t! q" W y3 Q" f# u char trans[1000]; v: u: @. _2 N' s: j2 ~ char wrong[3];+ K& v8 R: k. P ?4 b# S$ D
scanf("%d",&N); G7 |6 }. c& B$ Q- b gets(wrong); % K& D3 ^* M! z3 {! [* U8 Z int h=1; 4 l, m/ ]! e, y! @9 r% _& ?' v while(N--)' S' E8 {7 Q- [- a
{9 t6 \ D7 z+ K2 Z1 J
gets(code); ; w1 q( S6 O- T* m: _7 r gets(map);6 n0 o' n- A- a
for(i=0;((c=code[i])!='\0');i++)" @" F3 k2 V; Q
{! S! n1 m6 @5 K% ~7 m3 G. q+ N, Z
if(c==' ')trans[i]=' '; 3 q4 v1 k. j2 [3 A else {j=code[i]-'A';- f- W/ Q! E1 u% w/ d
trans[i]=map[j];} }/ t5 m8 P9 @7 w; T0 U
printf("%d ",h); . w# t$ p @: w- a, I for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++); j3 n, j0 a! f, E$ ^
printf("%c",trans[i]);. q8 u3 @& D2 P, w$ a0 q8 K
h++;6 x8 l- j- B! q* b8 g: z& i
printf("\n"); 6 T, [( t& Y1 L& U& [3 q" ^ }. B& v$ I a3 Q a, U; M
return 0; - s+ z$ C- R& }}) X& l W5 z. u& `. U7 V) l