7 B! {' B( J* q2 w; c ; L0 l- D' K& Q$ C* Y5 tTime Limit: 1000 ms Memory Limit: 65536 kB; v; C8 A: a8 k1 W2 g" R$ p: S
Solved: 79 Tried: 281 ; Y7 V% x' w4 O7 `8 x6 o 1 M) S3 D3 ]5 X! z1 d* ]Description 6 }3 X/ k! t$ e/ ] L) ?A cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: X8 B8 z3 W2 P2 O, P
/ l4 d' [" S, T: Q
Encoded: HPC PJVYMIY 0 l5 Q6 G- S A- D2 \
Decoded: ACM CONTEST$ \) o6 u( ]/ y9 x% Q8 Y7 v# R
0 Z6 c& \7 G8 o! `4 \1 h/ L
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. 2 G" u% c9 ~4 M8 u
9 j9 [7 Y C) @" T+ o
# ]* W' A- Y9 b8 S1 V7 ~Input * ?# N; R' @5 S) [! Y C2 J
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. ! q' ^, M# V9 S- F% K8 Y; J/ B0 Y5 k, m& g+ _6 y
0 O8 `" x. q3 A* x; v4 i
# T6 ^8 V- X- Y! c
Output . B L, |4 Z- u' ` U/ eFor 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. ! v" y* v# p& Y7 M& i* f5 L4 s: F* _+ `# J. u: @! b
( E# ?& M- H7 l6 XSample Input ) h0 o& Z9 t7 W" {* w3 u' E/ q
2 # o& p$ O* q K$ z# ]% e1 OHPC PJVYMIY + P# p1 ^; Q% R+ b9 h
BLMRGJIASOPZEFDCKWYHUNXQTV , X0 e, r& O8 `9 Z
FDY GAI BG UKMY + Z' m/ M" n M; pKIMHOTSQYRLCUZPAGWJNBVDXEF W( W8 v+ T6 t; H0 n. k+ t; ]- Y
; {# V' N/ a3 }1 a4 y8 D8 O
& h. r6 E1 E8 ]) {2 o
( c7 a, j% |) |$ ~Sample Output 7 W- K+ D' V1 l8 s
1 ACM CONTEST % K; c$ e5 _4 e q+ {
2 THE SKY IS BLUE ( C) o8 d& N$ T 3 @$ j9 Z: P3 J ( S; \* E* D$ T6 o$ c. L v) O # `' F% Y) }+ ^我的代码是: 8 s2 b, @# k, _5 B- Z#include<stdio.h> 5 A! c5 z" s0 a( O2 }8 a#include<string.h>& n3 L+ d1 _* l( U. P
int main()# n: `' C; j! H* A7 s. ?
{ 8 N3 i3 @1 ] `; H" O" O int N,i,j,k; % y7 v e0 m& m4 e+ D1 [2 @1 t char c; 2 k) i" [4 @: O5 r char code[1000];) t4 m1 F* K8 ?6 p
char map[27]; $ F4 O$ R* w$ w# J/ C' _/ G char trans[1000];2 H: V4 a5 b2 j/ r/ z+ F* Y% y
char wrong[3];+ K/ S: q3 C1 p8 E
scanf("%d",&N); " R4 a1 F0 r2 K% S( y7 h3 E8 t gets(wrong); & }* |- j5 b0 |7 ^2 t) U int h=1;% i( F4 r' Y8 f" n% ?8 V2 G6 Q
while(N--) 9 }) d. p! t) S0 }. h v! ?6 i {- y5 W. z6 [& }# n$ X+ T2 ]
gets(code);, q$ ^. d8 Q" M K
gets(map); * c# a- @# b. ]- a7 d for(i=0;((c=code[i])!='\0');i++)) o, }0 D' a5 K7 y* M7 Q
{ t) H. e' X4 N if(c==' ')trans[i]=' '; , o- K0 R$ S1 K: y$ ^ else {j=code[i]-'A'; ! K. X! v/ ^" [. g2 k, s trans[i]=map[j];} } 6 A1 C& Z8 k4 J2 Y printf("%d ",h);/ m/ g) \% R) ^5 f) K% }8 {" f
for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)- D0 V: G5 w1 W; _. c* T) y H$ t% W
printf("%c",trans[i]);! I; ^! w' J) f( A
h++;+ D* T9 q. S! {
printf("\n"); : e: L$ h d# Q8 t8 a }: c0 m t! \$ Y, @
return 0;7 E$ @& R. K. G8 p# L
}$ A8 ]5 r" I0 p7 l1 B5 J
8 m# v0 |3 ]5 }