QQ登录

只需要一步,快速开始

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

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

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

1

主题

0

听众

2

积分

升级  40%

该用户从未签到

跳转到指定楼层
1#
发表于 2011-3-19 15:26 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
Cryptoquote
5 s& K$ s, t1 |5 }# ~; `0 x8 t; K7 y, W9 x; j( ]4 n
* C. `7 S! i% l1 m: C; n  a
Time Limit: 1000 ms Memory Limit: 65536 kB; R5 z  x2 o8 q5 M! i. Q
Solved: 79 Tried: 281 # ?: ~. d- f0 m7 N, g! ^

( G3 g8 ^; w8 o% zDescription
6 J! Q9 |$ Y0 C  N% \' bA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example:. i* l; m# n; G. T' }% p

# H) d; O! \7 U+ _; U) BEncoded: HPC PJVYMIY # `; l  s6 t8 m
Decoded: ACM CONTEST0 ^, Y. U7 ]' U, M. H6 L! t
3 L: ~6 S& ?6 F9 Z; w
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.
) S& R% s2 B3 g5 i# @
8 S% w: j1 E( t+ p5 S7 }4 {" [, S* W5 U2 O2 _4 A* ^
Input
3 J; q! T, ~+ Q7 j3 i3 Q* `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.- V, r  c0 W. p
( o( R$ m; \7 A$ {3 L! ~9 V
% K; c# e  ^& D- q/ S8 @

+ u- B+ C6 `3 K* W% yOutput ' ~) Y+ M% N4 i$ S; i
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. * ]. X. Q# e+ @" O8 g
# D# x: a& ~" ]9 {# t

2 s( F: z/ V7 I; qSample Input " |. R) T7 `) u7 a( Y/ J
2
+ s6 l' Y/ f0 wHPC PJVYMIY # @! c" E* ~, {# X7 x4 e
BLMRGJIASOPZEFDCKWYHUNXQTV ) r1 C  c( S8 h) J: d
FDY GAI BG UKMY / Y: v1 ]6 O( R, f# R
KIMHOTSQYRLCUZPAGWJNBVDXEF, x$ |: C9 d9 D5 @9 M; W7 B3 T, i3 o

* e. Z8 C" o- L# e& n: t. w  H1 s! |2 H: z+ V5 g% D" V
2 r! V5 V0 x6 i- `6 v$ g. d9 e( E4 Y
Sample Output
, @# H, ^: H4 a) g1 ACM CONTEST
1 u) z5 o3 T4 Y  _2 THE SKY IS BLUE' @6 k& ~6 ^- n4 K# y  @

6 ^6 s3 T" q  G& L1 R/ Q: a+ i2 L& D5 w& j
# W6 L  e) H4 f7 i
我的代码是:5 u- b6 m3 v# G- c# P
#include<stdio.h>/ n9 ]" [, J* H  p, ^# ~. m- U/ ^( w
#include<string.h>, X6 G% w4 C' l  a, |; A
int main()9 X# k/ K% q6 D; u2 {
{' o$ S* F7 y7 a1 }" C! `
     int N,i,j,k;
* e4 [& K$ ~. }- k     char c;* @; P# r: P3 H7 I# j5 w
     char code[1000];+ N! S0 M9 t  c  E# `1 y+ l
     char map[27];" _4 J8 o* X& o" T2 H
     char trans[1000];+ l0 L) q; _" ?3 h! G
     char wrong[3];1 L/ S2 y9 t4 R* S- q
     scanf("%d",&N);
* ?, f: u- p" C' H8 Y" r9 a     gets(wrong);7 W1 J3 ~2 o/ Q$ C* I
     int h=1;, T! ~2 h; m" q6 J
     while(N--)
, _" f2 c2 k, q5 w5 I, O& k9 W     {
! ?5 l) D' [$ L3 D- e2 y         gets(code);% x- Y3 K0 B9 _- q9 x' R7 w# L
         gets(map);  q8 {2 w# j; [( q! Y
         for(i=0;((c=code[i])!='\0');i++)
, _) H5 U% {4 v: n% B         {
: U  y, ]8 P+ I0 m             if(c==' ')trans[i]=' ';4 \8 {! \( y' a  u2 [2 Q
             else {j=code[i]-'A';! R9 V: O6 @' @$ G" a
             trans[i]=map[j];}       }
. D  I$ _5 Z" n0 T* p( D) s$ G         printf("%d ",h);
- \5 D( n+ K- o+ E2 o) f         for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)
/ T1 S! F8 @4 u: G! R         printf("%c",trans[i]);5 f  r, Q% w, D1 u9 j
         h++;
5 H' }6 r5 {( Z  n* v8 E         printf("\n");: B9 W2 G: w# K$ {8 l  O
     }
' n! w! F1 G8 i& E9 B: U/ [     return 0;
( v6 d) g- [6 L$ U+ F' Q. Q' f6 |}: Q6 m* ]8 H1 ?! |7 x
4 ]! U% P7 ]+ u$ L" q6 r; N  E2 A# F

: \3 z1 j. ^5 Q5 o8 P样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱?
- u$ O. Q3 `6 C9 s& i' S
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-29 04:04 , Processed in 0.499180 second(s), 83 queries .

    回顶部