Cryptoquote ' k4 ~% F- {& Q: e) h
& G+ D4 g |% o H5 w+ L, w
0 Y) B0 `4 _% G2 s% ^$ s
Time Limit: 1000 ms Memory Limit: 65536 kB6 R T* T$ i3 d- K4 @
Solved: 79 Tried: 281 1 f \; S' d4 E! V, Y# m
. X- M1 |' N/ ^! cDescription ! a: p7 w( N) @* [; H; j$ ?+ P) N
A cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: 0 o& q/ P0 V6 Z' f; W4 ^* `, F+ g I$ U( c+ K" ^& g
Encoded: HPC PJVYMIY 2 e4 f- R+ K, Z0 p- p9 d' ?; H( E( @Decoded: ACM CONTEST $ _3 [8 Q6 v+ ]" ] D3 w' s7 e Z- 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. 5 ^% r0 A. M; X. ^+ n, z
+ G% E( K! w: }& C2 m- x k& `' l s F6 L, I ]' {3 \Input / W+ p6 g' [& U. HThe 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. ! Z9 Z2 P- f% j$ j" ]( ^. ?( l$ ~( s
: A3 i2 i; z, p% r: y1 m
/ y" L( R/ @- X+ G& sOutput , g, f7 s8 W; y; z6 J+ _. 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. . c/ ^5 L. v% l0 K, x- _
+ g3 X+ L' q; n, U" J7 G/ b; R) _/ ~. u) S5 o
Sample Input ' i0 j! W7 h' Z# R2 s* }6 B/ a2 0 `7 o [/ n: d1 q. {HPC PJVYMIY 8 z1 ]2 s; ?2 cBLMRGJIASOPZEFDCKWYHUNXQTV " v1 g1 I9 N9 b/ T. A
FDY GAI BG UKMY 6 D9 [; x) j& @ {8 e' `
KIMHOTSQYRLCUZPAGWJNBVDXEF # F3 K# }8 ]9 A8 |/ Q9 G, u& D p1 O4 p0 @ t
( W) B: y: @- A6 ?; i* \
- f' F4 r6 G9 o( }. @# nSample Output 5 c! y' w" K7 E6 v* Q
1 ACM CONTEST : a; m* K/ ~4 [! W+ e. t- D* m& E7 d
2 THE SKY IS BLUE ; K( s% O: q7 c- G9 l& w$ i, v( x( A0 z$ N/ I! p1 j8 G
( j# K! k+ }5 u6 @2 ] C" _
- W3 T# U; W/ A' ?% q% [
我的代码是:8 [! W/ W* Z. S7 q( t3 t( n ~+ ?" A
#include<stdio.h>, i% i. M6 s. }# u; y" M: `
#include<string.h> ) D& |5 ?1 ]: ~int main()8 I( b, t9 B/ R8 [- G
{. r( t8 R. n& r" i5 F
int N,i,j,k;- A3 e7 @5 M9 O! [
char c;2 g2 E4 M( r& h2 s. @2 K2 _6 V, x
char code[1000]; / Q: F* I. f/ g char map[27]; , x V/ h$ s) B4 ~, L% a char trans[1000]; o6 h, n4 Z: f3 T* d
char wrong[3];7 S: @7 f( B9 E! T1 O! B
scanf("%d",&N);/ x: D$ N9 h, Q' D/ r6 G; J
gets(wrong);6 W, ~) x* D- x
int h=1;* ?/ x( C; i) X4 r# N8 E
while(N--)9 i) n, a2 V6 T, l/ I' R) U$ j0 T9 L
{ {' O+ d. {! @. \! {7 l gets(code); 3 k, p& `- C4 G I) L! ~) l5 \3 k gets(map);) Y+ x4 O2 I" s6 D* Z7 T
for(i=0;((c=code[i])!='\0');i++)8 Y( k2 `( p5 x: `& v
{8 ` X9 L" C- j. ^
if(c==' ')trans[i]=' '; 2 s6 y2 D9 s7 W" a4 [ k; d else {j=code[i]-'A';" y) A9 q# G0 d& E
trans[i]=map[j];} }$ V& u8 Z! S- |' c
printf("%d ",h);* c4 f& \' e; b |+ B
for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)- _; U; r* r9 Y; C
printf("%c",trans[i]); 0 N8 G/ H& o9 f9 |- a( H- [ h++; 7 S& r: z# f6 ^1 T! M. p" d% M$ H6 y printf("\n");2 M+ ?$ t- k; Z
} 0 U# O. l; ]# G8 n9 H6 w+ { return 0;% D; ~7 T0 R! _2 b! y: N: h
} 7 y w: U7 ~7 D- B3 {( I$ s" q2 A* t) j( I
) X q! {6 C* v# F% o
样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱? 0 m- P7 ^: [3 ]5 J# Y8 ^