QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 3786|回复: 5
打印 上一主题 下一主题

谁来帮忙看一下这个题错在哪里?

[复制链接]
字体大小: 正常 放大

1

主题

0

听众

2

积分

升级  40%

该用户从未签到

跳转到指定楼层
1#
发表于 2011-3-19 15:26 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
Cryptoquote . f1 A  A" I& @$ P9 Z! j
' Y; ]8 r# d/ C" l( L% V1 k9 e

1 e0 W& s$ o; a0 [+ x( A! ?Time Limit: 1000 ms Memory Limit: 65536 kB6 b  j! L/ A7 i) _- _: D
Solved: 79 Tried: 281 ! r0 s9 K: `) C: \/ N

0 }( f8 B1 M! Q  \+ B9 @Description
0 N; s: q0 q# \# q' s* ^  OA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example:
7 {+ s9 @; U' x% \- O+ d' w/ Z8 O* w( R; i( ^
Encoded: HPC PJVYMIY ( Y) f: i" h: U1 [, [9 l
Decoded: ACM CONTEST
: B$ G6 \0 G3 ]2 @
/ p$ X- Z" f: I8 ^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.
" U5 i3 e6 m7 k; q& W
4 f7 \& D4 W, Z
/ t! i2 z$ }9 s) TInput ) {* H5 p* G2 v/ n% [1 c  h% ^
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.
6 m' a0 T/ X$ [; S3 `7 z3 |6 F5 |; I3 }; k# G# B$ A2 z9 g/ v

8 Z7 J6 G7 F4 Z3 K0 F5 ^% o3 G$ b* P: ^
Output 3 H7 I# i0 F4 K' D
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.
, i3 _2 R% i5 u1 ?( t
1 D' @5 ]( ?  {8 G0 y7 A
  n/ G8 a* ]6 ?" D2 x$ }1 P3 i: WSample Input
: O; d8 o; P8 Q; A2
* ]- }. K. }3 V' p0 A* cHPC PJVYMIY
' _9 j3 \& A! |- @BLMRGJIASOPZEFDCKWYHUNXQTV 8 y# B% q* ]( P% ^) L
FDY GAI BG UKMY 7 o" z. u1 m9 p; S( d9 E
KIMHOTSQYRLCUZPAGWJNBVDXEF3 `' ?, @6 P6 L* B$ v. C
$ R* b4 L6 B: ^

( |2 W0 W) X- |* {$ }' M5 [7 r4 S3 s
Sample Output
1 X( t  V: @9 ~: H1 ACM CONTEST ' \1 {4 }6 A/ Y
2 THE SKY IS BLUE
  E7 X' [  G* q3 }. l. |; e
7 P+ q3 R# n: G4 n$ q, ]* D- q# X) e3 l* x5 _0 k7 g6 a7 o
5 Q" ?  o7 Q" R8 O7 w, H8 c
我的代码是:
/ s& t$ ]# [" c4 ?( z#include<stdio.h>7 z$ ?. u7 Y: k# k# B
#include<string.h>
. S' P9 m$ ~- }+ ?. rint main()
! J% d9 C. O: V! L{6 r4 v. r6 q2 X5 y( F# G* }0 h
     int N,i,j,k;
; j+ c$ b3 Q) z$ k" j2 U     char c;
4 R, G4 Z, [( U/ W3 I+ p     char code[1000];
( _0 `1 y  m0 H     char map[27];
, M/ o: p0 s/ x1 |$ z- J) S- q     char trans[1000];- H5 W; Q) U9 c" q+ M  w9 H
     char wrong[3];4 I, H$ d9 W: v% J/ c+ g
     scanf("%d",&N);
' m0 G+ J& F1 e$ s+ f2 s     gets(wrong);- C  v' ?9 ?5 {3 V& y$ i  U. D
     int h=1;1 R" T3 g* _. `# F8 `- U% o4 G
     while(N--)  H6 ^& l" U# k2 k* R( d
     {
; V1 I# a6 t6 ]         gets(code);/ H2 v* L0 d+ u; B  ?% o0 W9 Q
         gets(map);' `  b  Q: Q" S/ ~3 k, o4 b0 I
         for(i=0;((c=code[i])!='\0');i++); G8 s; x8 L( r
         {
& O: F6 o8 x5 v! e  e* n1 b( n             if(c==' ')trans[i]=' ';4 u2 X; V! k; Z4 f2 c
             else {j=code[i]-'A';
! _# M& N8 }! a! ?             trans[i]=map[j];}       }
2 T6 b/ W& L) w         printf("%d ",h);
/ d/ K* b8 T4 I! c         for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)
$ m% B0 w$ X- k: E         printf("%c",trans[i]);) L" k0 @" f( d+ n$ T
         h++;& p5 a  w1 l* v4 Y
         printf("\n");7 p. H* g2 r7 k& [
     }8 |$ N( V: [) b' f
     return 0;
/ Y# I6 P2 Q/ r3 H1 s}
* L+ l) d3 q; k& J9 [  m
7 z0 |6 X  A: D
: B* i+ g% ]* \) o+ m' f样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱?! z- |/ l  o0 L+ ]8 z
zan
转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
zjqylcy 实名认证       

7

主题

5

听众

1205

积分

宇宙无敌霹雳大头衔

升级  20.5%

  • TA的每日心情
    奋斗
    2013-5-18 15:14
  • 签到天数: 101 天

    [LV.6]常住居民II

    自我介绍
    男~~

    新人进步奖

    群组杭州联盟

    群组小草的客厅

    群组C 语言讨论组

    群组数学建模

    群组数学趣味、游戏、IQ等

    回复

    使用道具 举报

    57

    主题

    5

    听众

    1031

    积分

    升级  3.1%

  • TA的每日心情
    郁闷
    2012-11-15 14:48
  • 签到天数: 120 天

    [LV.7]常住居民III

    自我介绍
    为人随和~~性格开朗,喜欢交友!!

    群组小草的客厅

    群组2011年第一期数学建模

    群组岩土力学与地下工程

    群组数学建模

    回复

    使用道具 举报

    linmatsas 实名认证       

    53

    主题

    13

    听众

    3591

    积分

    逍遥游

  • TA的每日心情
    奋斗
    2014-12-2 09:53
  • 签到天数: 54 天

    [LV.5]常住居民I

    自我介绍
    额。。。。世界上最讨厌的事情就是自我介绍。。。

    邮箱绑定达人 新人进步奖 发帖功臣 最具活力勋章

    群组Matlab讨论组

    群组数学建模

    群组小草的客厅

    群组2012数学一考研交流

    群组C 语言讨论组

    回复

    使用道具 举报

    2

    主题

    3

    听众

    181

    积分

    升级  40.5%

  • TA的每日心情
    开心
    2013-5-9 23:17
  • 签到天数: 14 天

    [LV.3]偶尔看看II

    群组Matlab讨论组

    群组狂热数模爱好者

    群组数学建摸协会

    群组学术交流A

    回复

    使用道具 举报

    3

    主题

    3

    听众

    39

    积分

    升级  35.79%

    该用户从未签到

    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 注册地址

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

    关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

    手机版|Archiver| |繁體中文 手机客户端  

    蒙公网安备 15010502000194号

    Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

    GMT+8, 2026-4-30 22:42 , Processed in 0.482816 second(s), 82 queries .

    回顶部