0 d4 A! f3 B8 l8 hDescription ! A% e, c: C U; b+ y" LA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: ; x# y8 F- Y4 E* l( `, o# w' P: R ) K5 N+ T$ z" C' G' h) T3 ^Encoded: HPC PJVYMIY : d1 q, n* p/ N) eDecoded: ACM CONTEST! z( U4 Q" I# K/ Z' A+ v( G( r! U
8 V' u( E+ H0 Y
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. ! d3 C! f- ^/ X! W% p- ? w& G8 ?/ M: ?$ d
l2 m% B/ r% S; bInput 1 Q! Q% ^9 f2 F# x) t/ U$ z' }4 R
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.- ^" a0 N3 s a \4 u- N" w
3 ^9 L* U3 P, COutput + e& v6 }% G, A3 |
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. / l1 {# B. A1 s3 d) Q* U8 }3 P4 c P
# k' J, U+ r+ f% ^& U' z7 x# D7 W# g
Sample Input % o! N( e+ z0 d+ K7 q, i! q2 / q3 P" H* I& G3 h2 o; i+ tHPC PJVYMIY 1 k. M1 {& O! I; _' `0 k3 `BLMRGJIASOPZEFDCKWYHUNXQTV 6 p) c$ x0 T, [8 u5 p+ N5 x# o% l8 HFDY GAI BG UKMY ' A* ~: H5 R( {7 ~9 O2 I1 ZKIMHOTSQYRLCUZPAGWJNBVDXEF5 _1 {- ~5 R$ x; I
8 q3 {0 W3 R, g! {$ w. Z% ~/ M; H6 t
) N# Q5 K" j5 b+ B8 ?
) `7 _$ p3 p7 P# N& x0 e2 qSample Output ' A* I8 P7 n" N# K, k) L; i8 ]1 ACM CONTEST : h4 N& N/ G* S6 b+ |2 THE SKY IS BLUE7 X' Y, ^0 F, d. N. M# I) B
4 i% u3 t3 L J# \# [" o" A 5 k/ M# C& q* d/ I8 g8 [ B) U 2 J* w% ~5 \4 [8 H2 H- q) w我的代码是: ) f" L A" K+ }2 \# A#include<stdio.h> . M, O9 f9 S7 h5 c( x#include<string.h>0 [1 j! J6 O0 q* _1 g
int main()/ j/ K6 Z+ B5 o! G* q# c5 x
{* k- X# q4 }$ z- {' t7 G
int N,i,j,k;, y$ T. W( D _, e' }: [
char c; x8 k' n2 J4 S4 F9 w4 T
char code[1000]; ! D9 B; \, i& Q char map[27];. R) A8 }9 H- z# Y% @8 ?+ W) N7 a
char trans[1000]; 2 m0 w# G2 _/ F char wrong[3]; 9 j0 h. D) i, U& Q2 }2 r! N scanf("%d",&N); # N& }# s. q! H, A- V& c gets(wrong);3 E1 G/ l T# q t( K2 t
int h=1; 3 T8 ~! j+ ^$ u* x5 ^2 l while(N--)$ w1 V1 o, K0 u
{+ j1 o3 r1 [/ U3 z
gets(code);' J! x% g9 r6 f- ^4 Y8 ]( W" v
gets(map);9 X7 d7 n5 o! a
for(i=0;((c=code[i])!='\0');i++) / t* V$ T" F! E {/ D) I7 l6 w$ S/ F' e
if(c==' ')trans[i]=' '; 6 r& _5 X- [ P& a6 a7 L. ] else {j=code[i]-'A'; + B& l4 d7 S- d: G7 D trans[i]=map[j];} }' ^# y' I. U7 u* f) w/ G; I; E" P7 |
printf("%d ",h); A1 b9 G# ^% M9 @: E
for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)" l& \; r/ w4 {3 t, T& {, K1 L- C
printf("%c",trans[i]); 0 v4 Z4 q3 v0 v0 b h++; $ \! J( [. T* G" g7 ]8 e# S8 f printf("\n"); 9 O2 F3 O$ i) T7 y' R* X! q } 8 i$ ]8 |7 X7 f, E2 C0 k return 0;* l* ]! f/ q. [8 W2 Z
}9 G1 F8 f% z2 S# M