Cryptoquote ; M- X6 O o' F; {+ `
* e8 P, c/ x6 f
, t! t% K& N8 r8 G
Time Limit: 1000 ms Memory Limit: 65536 kB% F' @9 X* G! o! n
Solved: 79 Tried: 281 ' r9 Y) T$ i! ~ 4 t0 c7 a7 Z% u# d( n+ ]# `- L, EDescription - \4 q! K& b! \$ b; a9 e" ]
A cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: ! A8 ?0 ~" w/ f' c: c( j6 o' |7 e+ K, B
Encoded: HPC PJVYMIY % ?) C( m+ d( Y2 Q, iDecoded: ACM CONTEST% [+ H' j. M, }. q- L) K1 H
: v! `+ E( r+ E: ~! R# R! O* @
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. ; Y7 W) T M' N1 J; k; V5 F- f) F0 q
% N! R- A; |# a+ q7 nInput 8 b8 l: j* Y7 H2 _4 J" O9 O4 b
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. % W' E( j" h9 a: N( c; z5 Y" `7 f0 i" B6 h) K
$ K: T5 `4 w6 x% v$ E7 k% v- _1 i9 a7 _2 |' Q" x
Output ; D& }; [& s ]+ b! r
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. ! _# B5 ^5 T4 C/ U
% R& m, g0 W' r$ [+ ^. K2 l: J- \% A% K; e0 H* o2 `' H
Sample Input 7 M. o* c8 U2 \( x
2 $ D% e; S e+ s8 YHPC PJVYMIY 0 D7 K. C: [! O9 cBLMRGJIASOPZEFDCKWYHUNXQTV 1 Y. z0 J1 d! c# A6 w6 \
FDY GAI BG UKMY 5 {5 z |( M. _; P& W7 ^2 UKIMHOTSQYRLCUZPAGWJNBVDXEF" E- I% k: I4 f
' f9 Z ]! q- |) @2 O
/ W! L* v( |' y( ^7 Y6 S2 R5 A
1 v5 O3 k3 C# c( S* I- ^Sample Output 0 {/ G t# R; W( K$ o3 v1 _; Y! T
1 ACM CONTEST & G; y: w- s* p3 d) k Y
2 THE SKY IS BLUE ) q) Z- n# s! f. y0 v8 N* l3 I. l0 L$ |+ K$ |, g9 H
. m2 p3 L+ C- c 5 e( Z% S }" i/ t( n! G0 x. X我的代码是:: f! M- x, E4 {0 C' e# Q
#include<stdio.h>. R# _0 D8 v& \& o* |+ b3 o
#include<string.h> - ?2 K6 n# r" S" g- Q& Zint main()' s( y& l' W- _$ q' S; k+ e% d
{4 ~1 D+ v3 c% I! v: @
int N,i,j,k; % j( n6 q( T8 d char c; 9 s0 q8 u5 ?0 [- @, E# o& R7 s char code[1000]; i4 ^0 l! O2 p
char map[27];8 |( k' ?4 e$ {* m* ^
char trans[1000]; }0 l! g+ W } char wrong[3];- Y j1 u$ i, Q2 i# X; V
scanf("%d",&N);; H$ T6 e/ l# e& N+ o; I( }
gets(wrong); ; n1 C- i8 K( F+ a' ` int h=1; 9 z4 x1 S" u4 f1 l" d1 d while(N--)& f1 [% G5 C9 Q: \: L
{ / ~* U: C: K0 F, n# N2 p: `- E gets(code); 4 C' V6 S4 l. G$ [* Z- C gets(map); 6 E$ j- g3 Y- c; a for(i=0;((c=code[i])!='\0');i++) : c) k4 D1 t& h; W2 R. f { * D* I% |* b) `& D5 B2 a9 d0 o if(c==' ')trans[i]=' '; o$ a% q2 ^& P0 H
else {j=code[i]-'A'; 8 q/ \6 G3 `8 F1 D) C2 F trans[i]=map[j];} }; n! h& Y* y- C
printf("%d ",h); 9 e9 S1 |4 e; v+ t& u, }5 Z; V( w for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++) $ I" b( q& @4 R7 r! H printf("%c",trans[i]); B, l& ]4 q% M- \' T) l h++;& v {: Y( W7 a& P F: T
printf("\n"); 5 t- ~8 J! K$ X) }7 E' p } 5 y5 z& y1 ^3 Q9 s* ~ f return 0;! `2 H0 t: ?- p& l5 z) ~: H+ ~
}( l4 a$ J0 o+ p! T. ]
% s3 c5 `" k! O+ K; e% O! P