Cryptoquote . O3 _9 X9 Y& C/ a2 J7 W e, C+ A. M1 y
' s' F6 Z/ {; A: r1 r1 XTime Limit: 1000 ms Memory Limit: 65536 kB ; ?" c! G- F; A( z* W( }+ ~Solved: 79 Tried: 281 9 e9 b( }5 J* G* x& K8 z. H" r
$ o' L4 {6 e( ~+ m1 K4 i. ^. u' u
Description . P l% Q# ^; l# P
A cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: + X9 A8 ^+ b* E" G6 b! }8 J& x; C. p5 C2 U- c& G0 e
Encoded: HPC PJVYMIY 6 m9 G, t0 C2 T7 W0 a% I
Decoded: ACM CONTEST0 V1 K2 f& A3 x' c* ^% ^
% R, L9 n5 v( |6 ~8 q: {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. 4 l6 t1 X3 ~; k5 k) f3 h. x2 R
: l% c" e* j% i0 @+ K9 T8 t; D5 R! C% w
7 w/ ?# l7 l: r$ y/ C3 I$ \( _% q
Input & `; D. e8 l' y4 G$ I' _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. . z- p0 {( M0 S7 ~% H$ W $ w$ X+ L2 }: Y2 ]/ U3 M4 r8 _- L, V( t5 o
( K1 h) ]% X, j: j @8 A, I5 b! M4 [Output " O( r: P8 N { f' H6 s
For 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. R/ C: _0 t6 z3 N- ~: {' m- A# Y) t! K! r# F l$ }
~$ |+ y% Y# L' A, b( ESample Input % ^& V1 N* q D5 _" d
2 & n- ^" U1 b, e* i% mHPC PJVYMIY : x# u- s E4 ^BLMRGJIASOPZEFDCKWYHUNXQTV " T/ M' M6 g" L4 F
FDY GAI BG UKMY 3 H8 X0 f1 X0 ~5 t0 {$ {6 KKIMHOTSQYRLCUZPAGWJNBVDXEF+ } A" A2 x- h* \! n1 B6 `& U
1 X+ E K& [+ X; y& D 8 M) Y2 L! S+ I7 s5 D# e # b) |, ~* D9 u2 y" T9 _& rSample Output - I, R3 c! Z6 h8 ^8 [
1 ACM CONTEST 2 O7 g4 S( p. H {; a* Z* |
2 THE SKY IS BLUE 8 X1 O" t& l5 w! [6 A# S9 G( Q \4 o+ l/ T( D
8 b3 |/ t) M% l7 ] * P" I* e+ O: T- c1 P J, n( J我的代码是:3 ?6 k5 l% a$ f; h% q
#include<stdio.h> % O5 Y4 P; ?( G; }8 A4 E#include<string.h>, \3 q; i% P M* n2 G4 t7 U( t/ ?
int main() 3 `/ m5 {7 }5 F. i) u{ % f: z2 `: r) Z- v7 o! J int N,i,j,k; m/ A/ Y O9 h9 n+ w. d
char c;+ i+ r( _+ [) Z Z
char code[1000];2 e. J+ S" `, P/ y4 V" z8 X
char map[27];) [, V. F, x" X
char trans[1000]; $ L% ~1 |+ r- l7 r char wrong[3];& O7 e0 z9 \+ B; @
scanf("%d",&N);* X0 c- N0 W4 s
gets(wrong); , y7 }7 |" o6 r' R) v6 P int h=1;# j7 w9 V' B( D9 \+ S( e
while(N--) ' e( ^! J5 N9 }/ R {; ~" H2 R+ U1 r' Z+ A, @
gets(code);4 F) A4 `! ] }3 F: q3 z
gets(map);0 g; t/ T4 k! |( S
for(i=0;((c=code[i])!='\0');i++)# q9 x, n& V2 C, @
{ : C1 G3 G! {" j; @" w2 G if(c==' ')trans[i]=' ';3 g3 }5 x- d o# K+ a0 u% t/ O/ y$ a
else {j=code[i]-'A';- e; {3 t' M1 ]
trans[i]=map[j];} } : v/ n' I( k6 N% k printf("%d ",h);: G; \. h, Y1 x u8 u( B, J) _
for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++) 0 @& ]( U! F7 }1 T$ ~4 U# f c; c printf("%c",trans[i]);6 X" J! m K/ [2 S; g6 u- B
h++; ) Z" J1 w6 m# n0 F printf("\n"); 1 F1 Z+ `* s! n7 F4 A7 e }8 {# E, {( R* A' f
return 0;6 V0 Z% w; |0 |
}% J$ l2 W8 e f2 O/ U% q" U9 a! x
7 h( u. D( f$ Y* \8 h3 ~/ U% |+ Z. p; T1 ~! t" v
样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱? : l! D' A- ?( t$ }) T