Cryptoquote 5 s& K$ s, t1 |5 }# ~; `0 x8 t; K7 y, W9 x; j( ]4 n
* C. `7 S! i% l1 m: C; n a
Time Limit: 1000 ms Memory Limit: 65536 kB; R5 z x2 o8 q5 M! i. Q
Solved: 79 Tried: 281 # ?: ~. d- f0 m7 N, g! ^
( G3 g8 ^; w8 o% zDescription 6 J! Q9 |$ Y0 C N% \' bA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example:. i* l; m# n; G. T' }% p
# H) d; O! \7 U+ _; U) BEncoded: HPC PJVYMIY # `; l s6 t8 m
Decoded: ACM CONTEST0 ^, Y. U7 ]' U, M. H6 L! t
3 L: ~6 S& ?6 F9 Z; w
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. ) S& R% s2 B3 g5 i# @ 8 S% w: j1 E( t+ p5 S7 }4 {" [, S* W5 U2 O2 _4 A* ^
Input 3 J; q! T, ~+ Q7 j3 i3 Q* `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.- V, r c0 W. p
( o( R$ m; \7 A$ {3 L! ~9 V
% K; c# e ^& D- q/ S8 @
+ u- B+ C6 `3 K* W% yOutput ' ~) Y+ M% N4 i$ S; i
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. * ]. X. Q# e+ @" O8 g
# D# x: a& ~" ]9 {# t
2 s( F: z/ V7 I; qSample Input " |. R) T7 `) u7 a( Y/ J
2 + s6 l' Y/ f0 wHPC PJVYMIY # @! c" E* ~, {# X7 x4 e
BLMRGJIASOPZEFDCKWYHUNXQTV ) r1 C c( S8 h) J: d
FDY GAI BG UKMY / Y: v1 ]6 O( R, f# R
KIMHOTSQYRLCUZPAGWJNBVDXEF, x$ |: C9 d9 D5 @9 M; W7 B3 T, i3 o
* e. Z8 C" o- L# e& n: t. w H1 s! |2 H: z+ V5 g% D" V
2 r! V5 V0 x6 i- `6 v$ g. d9 e( E4 Y
Sample Output , @# H, ^: H4 a) g1 ACM CONTEST 1 u) z5 o3 T4 Y _2 THE SKY IS BLUE' @6 k& ~6 ^- n4 K# y @
6 ^6 s3 T" q G& L1 R/ Q: a+ i2 L& D5 w& j
# W6 L e) H4 f7 i
我的代码是:5 u- b6 m3 v# G- c# P
#include<stdio.h>/ n9 ]" [, J* H p, ^# ~. m- U/ ^( w
#include<string.h>, X6 G% w4 C' l a, |; A
int main()9 X# k/ K% q6 D; u2 {
{' o$ S* F7 y7 a1 }" C! `
int N,i,j,k; * e4 [& K$ ~. }- k char c;* @; P# r: P3 H7 I# j5 w
char code[1000];+ N! S0 M9 t c E# `1 y+ l
char map[27];" _4 J8 o* X& o" T2 H
char trans[1000];+ l0 L) q; _" ?3 h! G
char wrong[3];1 L/ S2 y9 t4 R* S- q
scanf("%d",&N); * ?, f: u- p" C' H8 Y" r9 a gets(wrong);7 W1 J3 ~2 o/ Q$ C* I
int h=1;, T! ~2 h; m" q6 J
while(N--) , _" f2 c2 k, q5 w5 I, O& k9 W { ! ?5 l) D' [$ L3 D- e2 y gets(code);% x- Y3 K0 B9 _- q9 x' R7 w# L
gets(map); q8 {2 w# j; [( q! Y
for(i=0;((c=code[i])!='\0');i++) , _) H5 U% {4 v: n% B { : U y, ]8 P+ I0 m if(c==' ')trans[i]=' ';4 \8 {! \( y' a u2 [2 Q
else {j=code[i]-'A';! R9 V: O6 @' @$ G" a
trans[i]=map[j];} } . D I$ _5 Z" n0 T* p( D) s$ G printf("%d ",h); - \5 D( n+ K- o+ E2 o) f for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++) / T1 S! F8 @4 u: G! R printf("%c",trans[i]);5 f r, Q% w, D1 u9 j
h++; 5 H' }6 r5 {( Z n* v8 E printf("\n");: B9 W2 G: w# K$ {8 l O
} ' n! w! F1 G8 i& E9 B: U/ [ return 0; ( v6 d) g- [6 L$ U+ F' Q. Q' f6 |}: Q6 m* ]8 H1 ?! |7 x
4 ]! U% P7 ]+ u$ L" q6 r; N E2 A# F
: \3 z1 j. ^5 Q5 o8 P样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱? - u$ O. Q3 `6 C9 s& i' S