4 e! M$ N0 y& A/ t" S+ `Description . C7 O9 @; ~* B+ c o
A cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: ( a* u2 ~* w) r9 w$ J# v; O* l/ G! e( {5 y! J) \: T' ~3 M
Encoded: HPC PJVYMIY - a: J" C V" m) R! p5 _
Decoded: ACM CONTEST * x2 V) w4 S& E - h+ y9 p: @# YIn 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. 1 j% H* |7 Q1 H* `& d4 h; U4 u ( E% k' ^3 V; J) D7 A* D$ W) A) {. w" B/ j a7 A- v% a& n
Input , n% G! p. E# X# M
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. ! n. G% T6 K3 R/ C" D9 k9 v9 J" [ : {8 n% ~1 s; B/ } * l* q0 D4 Z" U" Q3 U! ? ! e8 D& W# I* A# h3 ^Output ' V* Y5 V- R6 h! Q; ]- 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. 1 {7 M1 G( E0 q7 B4 I- O, H r2 u% ]- G- p, X' H1 x' d5 u5 G d& H3 n: e
Sample Input , f+ a' q- j$ r1 M7 b
2 # B7 C0 S/ a9 ~$ v3 o% ~0 VHPC PJVYMIY % g1 a1 M1 y' ^; DBLMRGJIASOPZEFDCKWYHUNXQTV & X0 F4 u4 ]/ D$ y9 F7 QFDY GAI BG UKMY 9 H; g9 I+ ~( O6 Z! n4 yKIMHOTSQYRLCUZPAGWJNBVDXEF% y8 T- A" ?0 y9 X# O7 a2 I# T/ |
, O* z8 `7 C& m2 D6 N
5 X% F( J# S# O1 C' Z7 c' Q5 i+ ~
Sample Output + v0 l6 ~# ^7 {3 r7 r J
1 ACM CONTEST 4 I; X2 q4 B0 v8 i, Z# S
2 THE SKY IS BLUE+ ~$ I5 x' |. H M
% D* c. { i5 K4 l% s 3 A; [6 T& p% U' S% ^+ |) M6 v+ u$ u, r6 Z) R% @
我的代码是:/ z. J% F3 Q, b& Z9 U* w4 k" @
#include<stdio.h>* f f4 l8 B0 q& M
#include<string.h>1 \7 T4 a/ k5 `
int main()" J( T1 r4 [$ U7 j* c
{ 3 F1 K7 w6 E. w2 v, w3 ^' D int N,i,j,k;( x; V" j$ d ?0 r
char c;8 |# b7 W9 ]$ n& t9 E
char code[1000]; ' @0 F3 N1 V8 ?+ j! ^( u \% q char map[27]; 5 A5 r' N, A8 K7 f+ g+ N char trans[1000];! n5 q( Q% T0 r7 T3 B) ~+ S( ~' A% {
char wrong[3]; , G q2 e) y6 N, P scanf("%d",&N);' p2 W5 R. q+ p' l- L$ }
gets(wrong); 4 C! U2 U3 m( A3 q4 t- w; a) G int h=1; 8 n% x# f# q/ `0 Q" w- h2 _ while(N--) ; L- H$ V3 f; a1 ^( l' \8 N {) ]6 L g1 o3 b
gets(code);* Z' b+ G9 X, n. {) Y. w
gets(map);" Z' u) Z5 u+ C6 H0 {
for(i=0;((c=code[i])!='\0');i++)' @0 Z/ |& S. Y( o7 V
{7 l( T5 h0 N/ w" t. w% ^4 K, i
if(c==' ')trans[i]=' '; " _+ ?0 u+ @3 T7 V else {j=code[i]-'A'; & X, c P: } h% v trans[i]=map[j];} }) d+ O9 f- L7 u7 [3 t
printf("%d ",h);! N5 O- t& \# p$ X: i+ b y
for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)' t4 H1 ?1 Q; T4 b- a4 ~
printf("%c",trans[i]);2 k# g9 L2 V4 k+ z/ R! R
h++;0 g9 t- |2 j* M, z
printf("\n");2 D$ C) a9 g: V$ V5 m
} + n& {0 x+ y/ S return 0; ' @! {1 }" F& y7 l6 V* u3 H}, q4 j8 d- C& h/ x. I
& Z6 N/ u: e0 L
5 F1 H! V# o% Q
样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱? 0 {, s6 X% g0 W% _& q; [6 N