Cryptoquote / \* g. m0 w6 u/ q ? ! J5 I/ p* W$ z7 t1 b7 |7 M; K* R3 i" b7 p) Y
Time Limit: 1000 ms Memory Limit: 65536 kB% T, Q) F& u& x% @- \
Solved: 79 Tried: 281 % R! U7 w1 j/ D; w2 M+ W
% K w5 C6 s4 ?7 S) r4 ODescription 6 b* j0 z5 p& x% P; _( t6 vA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: ) a' q4 T& M) c% t2 {8 _) Q, m8 M3 e: @! e$ M% ~, m1 b
Encoded: HPC PJVYMIY : q: M- F4 {+ Y; X
Decoded: ACM CONTEST) L' B; {( y7 g% ^
* \$ z, j% O: Y$ E; W: P6 t/ x
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. ( P! b& y* x W& A' ~* _; b2 a O+ ?; l7 j N + @3 p2 G# `$ V. _' m4 Y% ^# gInput , g+ m) J! D0 a, H4 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.8 l Q2 S" x& G- g' Z) E
3 G4 C+ ]3 y; ]- m
+ M0 [7 x6 j- ?) ^3 o6 J
: e# G1 }: S! J6 v
Output 4 E) l& S3 \' ]; w4 ^4 LFor 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. 0 i! a+ S3 v: A c
3 G6 Q$ H* D# Z% K, f1 ]8 T
* d a g J" a+ b; G+ C' MSample Input 5 x6 c9 f5 @" M8 W, h- [3 G- _2 ! R" X4 ?* o5 p! |6 N, A* |
HPC PJVYMIY ; A* K2 r; p1 R* u0 @BLMRGJIASOPZEFDCKWYHUNXQTV " G5 a. A3 u: W/ i/ c% uFDY GAI BG UKMY ; E* \- W7 @9 D' SKIMHOTSQYRLCUZPAGWJNBVDXEF 8 H6 j7 c. k3 y! t+ P8 N9 x 8 H/ S% H2 `2 \+ |7 O/ e/ }- w5 k/ K
* A. g8 O* w$ a6 f2 `3 m
Sample Output 8 D1 s w; S, T1 ACM CONTEST , C" R7 l! q+ Q+ |9 H
2 THE SKY IS BLUE " A/ o5 K; b* i3 @5 Q ! I" Q0 f: `# v0 K8 [0 ?2 m7 M' a: u/ R! G
, ^3 f* v3 \+ _* [+ V" W3 X我的代码是: ) k- F: c: C4 M# y9 y#include<stdio.h># e5 {' x n0 }* }; Z
#include<string.h> ! {! ~* N" W& D7 c5 O2 iint main() 7 L9 L6 |* @ H{2 [) i+ m6 u5 |, ^$ U8 }
int N,i,j,k;# d5 `) [$ y. [8 y, g$ j( Q
char c;' U$ A; @: Q' | s9 R/ x
char code[1000]; , C& h% f' E. w$ R6 \3 S char map[27]; : t% v; k: w! l! r. N char trans[1000];+ v: N/ L! H+ ~+ |
char wrong[3];: g8 R8 T$ Q5 A2 E
scanf("%d",&N);: j# X8 e" k) s5 }9 M
gets(wrong); 1 O% S: B$ W: U# c' b) t5 s int h=1;: `% D7 h% e4 l
while(N--) 6 I1 `! R7 p. P( I, H/ k& l {9 ^7 a+ [+ s0 p0 t4 O: F4 f- r" w" |
gets(code); 6 E% m- z3 U1 s* \7 V- [1 ^) D gets(map); 8 ?% F. W) v' W; O for(i=0;((c=code[i])!='\0');i++) % J$ y: K9 `% O2 s# V: C- z. j {" }8 x/ d6 g, p- J
if(c==' ')trans[i]=' ';/ y8 m+ K7 b# z
else {j=code[i]-'A';# _6 _. h) G6 @+ s7 V8 N$ A, B
trans[i]=map[j];} }3 Z: n; v% @# W: d" k" g
printf("%d ",h); ' l' D0 i, t$ p1 S for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++), ^" ~! p: T, Q, P
printf("%c",trans[i]); & w! ~4 K3 m1 E) E0 }! c h++; % Q5 r. v$ x6 ]8 j+ a printf("\n"); $ U; u3 o# ^* l } 4 ^2 l% }# D0 z$ g return 0; 6 W7 n0 [* O2 X9 z. S}/ _& C# r1 } h! ~6 c
2 O2 q+ E) f9 ~8 C5 [. e# [; ~
: e* R; @! @ X) ]7 `
样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱? 1 g l# V& N$ ^: ^/ p# n