Cryptoquote ) r( g3 j+ g. ~& {7 w/ l2 t : S. V0 D% V! u" U- l4 x! M$ Z( D5 U
Time Limit: 1000 ms Memory Limit: 65536 kB ! c8 a& |" t; b6 ?. ?6 v- L. gSolved: 79 Tried: 281 - Y/ x' k$ Q5 h. A7 D6 G* M( |7 A1 i7 S7 o( _
Description : [/ Z& |) b7 z* z: K* D% \' dA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example:6 r. Z! K+ b: u/ `, z! U
. j7 Q0 W+ ^ ?; S
Encoded: HPC PJVYMIY ; ~, U: E: e( |" PDecoded: ACM CONTEST 9 _6 m2 e* A5 ]2 d& \- F. {( r7 l/ w* P1 \8 {! F; j2 H( e
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. ) I/ X/ \$ l; @- c
3 |+ N3 }. u# [% H
) n8 `+ P w. N A1 p1 B! ?. ~
Input $ b# E( I1 Z: j8 x
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.8 D8 J6 b% a- z: { @
* q- T8 O# Y' l
5 w( C6 F% _1 |
+ A+ A/ H, S" BOutput & ~, i4 D: h# GFor 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 [, \ B0 M' O: p& x- ]3 f % t! i# c. m9 }$ v0 c' e$ l7 c/ \& C4 @( V
Sample Input - t1 N0 p2 F: _2 V9 H' Y
2 % u9 _: E: O/ G$ E5 w* } d
HPC PJVYMIY . C; w* a6 R% Z5 ^) q1 k
BLMRGJIASOPZEFDCKWYHUNXQTV 8 ]/ ^) @: G9 X6 A0 M- zFDY GAI BG UKMY * ~% m8 h2 F* k' KKIMHOTSQYRLCUZPAGWJNBVDXEF7 [8 H/ _, g/ c, T' t
) _; W8 ~1 Q# r+ O$ d
8 x2 D5 I7 w7 _) X6 y ( |" O$ ^4 s/ h( R. g" pSample Output # Z x: c$ ~: V) R: O& z1 ACM CONTEST 8 L- g$ N, s" G4 g$ C
2 THE SKY IS BLUE $ {$ b& y' A9 s5 K, _7 ` Y; k. }0 y1 O6 W- ?
2 x$ o( z! I3 j
3 }% i8 H ?3 P4 K0 p& V
我的代码是: * _/ `: S/ Q; X5 R#include<stdio.h>2 ~) N* t4 d; R# N4 O
#include<string.h> , c" {# R/ N3 B* nint main()1 g& F5 H+ S4 U; Q# z- T+ n; M& j# }
{ 1 E" N: I- Z: }6 v$ [/ x int N,i,j,k; 4 u* n8 {& W6 r) @, M char c; $ n. x! ~2 g. s ]6 y. U* D char code[1000]; # d& _4 `3 D8 E) g; h5 K char map[27]; 6 M% d/ }1 j, l3 W8 ? char trans[1000]; 6 _# F3 L) R& W& z" \# ] char wrong[3]; # ^2 Q0 _* L, W9 W4 U( e; }2 F6 A scanf("%d",&N); 3 v9 D$ d3 ]& Z* {! S% k& k. E* [ gets(wrong); . s5 E6 L+ i. R( m; [: x2 K' ~8 J int h=1; ' w/ Y0 f. }, U5 M while(N--)3 B% W" C% w' e, `& @" M) O
{ 0 _4 Z, B. t! o I' | gets(code); / o* [1 U6 A, W$ g3 k gets(map); & V! \9 [4 s& c2 a for(i=0;((c=code[i])!='\0');i++) 9 }9 v* j* T! O- A { $ J& H% |4 y4 a& M4 k% {$ r! o if(c==' ')trans[i]=' ';7 v$ r! ~0 A% y# A, o0 t
else {j=code[i]-'A'; & z% `- [; ^* a# s9 ]& a trans[i]=map[j];} }$ H3 d! L4 J# s6 G! [) O
printf("%d ",h); + ?8 J }+ w$ v+ n" W/ w for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)5 H0 w- [6 x) l9 ]
printf("%c",trans[i]); , e2 o2 p0 n2 N9 Q# [4 I# x" g6 H h++;3 A1 c- ^8 t9 f; }; s
printf("\n"); " ~" q! z5 T: H2 |# [3 E5 Y } - X* l9 W0 g: B9 v( a7 h, S return 0;, [+ ^& T! u. o
}/ U* ~0 p- B( A7 E0 Y4 j
" ?: R5 h! |. z. o; m5 I " [# m; k2 h. W$ ^样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱? # b$ S. q2 C, u