- F: X; v8 j& O9 _' ~8 g: o7 k 9 |* J" y8 r3 c5 C( ^0 ATime Limit: 1000 ms Memory Limit: 65536 kB * w& n% P2 {: |; n# LSolved: 79 Tried: 281 ' A$ X# n3 N3 E' L 4 h1 u7 I$ n6 D, sDescription : Y- |. t( Q, t+ @2 y8 \. v$ D' QA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example:! r3 Y1 n# y9 |2 b. ~
, R9 y% z7 e: \$ y" g \Encoded: HPC PJVYMIY + e; c. c. X" r; ^$ h
Decoded: ACM CONTEST % E: V0 Q' { ~. I9 x7 Q& B3 W9 o0 y2 a( Q J. K
In 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. . w$ ` O1 z: @- E+ ~* Z
* E, S9 ?; m7 } ]7 J4 m3 o& m' }2 l3 o% I' g4 K
Input " Q/ B% V) w) M1 W( x. O
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.4 A9 V5 U: d$ N1 g
" d: ^3 ~1 m# V2 K7 ]+ Q6 U$ l* Y
( k- s. e& _+ Y4 M- Z 6 k1 O. M$ W, g/ r1 ~+ _6 SOutput ! }" \& G) F, xFor 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. 5 a( K& r7 {) K+ h8 `8 n/ Z3 v9 ?5 \2 z0 m; [0 K: C
" M1 ?! U- E Z6 r) ]: ?% @$ u1 [Sample Input & |0 K9 L4 Y- V* q% n
2 % f" N* i& {6 N% n& ]& ~8 E
HPC PJVYMIY ! y% h: X, ~' W/ X. jBLMRGJIASOPZEFDCKWYHUNXQTV ; u) d0 C' G* t* Z" ~# b* R
FDY GAI BG UKMY - U( s. t6 `; o" d2 H+ u4 N( e4 L
KIMHOTSQYRLCUZPAGWJNBVDXEF ' g- d% X! L; e& e ! ^( U9 v5 k8 }+ E- D+ ~' q' [) R2 S1 |2 z1 _
; S( F0 p( H) W1 G* u7 A m
Sample Output 6 ?( D* K* B, Z+ x7 }3 ?
1 ACM CONTEST ) l+ @; Z3 W/ C- {6 @4 [# o
2 THE SKY IS BLUE$ P/ T4 j. `9 C1 q7 D* h) H
- _1 ~* u- S- o$ b
- z U2 L2 p0 K$ |: o5 ~3 c Q3 | ; Y) Y* `4 ^1 Y; z z我的代码是:' T5 s+ G2 }% b. J" l
#include<stdio.h> : c) g) ^3 o4 J" z0 A$ Z#include<string.h>2 p( }. |- K ]8 T! U
int main() + h* ?4 u( H2 W6 k; x- Q( p# v{ 8 Y2 J/ g7 t! Z7 s/ D3 b# C int N,i,j,k;, E) Z$ q4 Q: j) d# f
char c;3 n( P. L! I8 {' k
char code[1000];, z, F7 M$ j6 _4 I& g
char map[27];8 I! w- E2 w, v0 @4 m5 m
char trans[1000]; ( b% S7 _7 c7 y' g char wrong[3];4 d: j, F" G O7 n
scanf("%d",&N);9 c4 S/ P: i4 h" [
gets(wrong);2 s: W% C2 D& K; p* B) l# ?8 n5 o2 b" g
int h=1; & m7 C! F, n3 j# h8 B) n while(N--)2 T& V: e& @$ E3 s
{ * r) Z: l$ C; t+ X# _ gets(code); : I" K- ~* P1 b6 A7 G gets(map); 1 `. x$ }3 W& U9 y& ]- m& ^3 P3 Z for(i=0;((c=code[i])!='\0');i++) 0 h' Y) t7 G: ?& j5 ` {& C+ M% \0 ^& q
if(c==' ')trans[i]=' ';) L5 q, B8 L. D8 o( o
else {j=code[i]-'A';) r! h+ k: ^ F, ]
trans[i]=map[j];} }$ `& K$ p, n1 E4 h% X+ a
printf("%d ",h); . I: m4 X; G5 X8 ? for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)5 t9 Q2 X, M- l+ N% j8 ?* F
printf("%c",trans[i]);( O* {5 b2 K0 J7 P) x
h++; ! D. B, j4 P# c$ h printf("\n");0 Z: c* w2 b2 ?( Y6 d% C
}" S, W. e; e) H# Z; x3 [
return 0; % J1 V" i2 @: g Y) ^" P2 T}0 u+ l( V7 |& g7 M8 m _: a. b5 Y
8 G4 g. k, e/ w! @