Winter_moon 发表于 2011-3-19 15:26

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

Cryptoquote


Time Limit: 1000 ms Memory Limit: 65536 kB
Solved: 79 Tried: 281

Description
A cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example:

Encoded: HPC PJVYMIY
Decoded: ACM CONTEST

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.


Input
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.



Output
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.


Sample Input
2
HPC PJVYMIY
BLMRGJIASOPZEFDCKWYHUNXQTV
FDY GAI BG UKMY
KIMHOTSQYRLCUZPAGWJNBVDXEF



Sample Output
1 ACM CONTEST
2 THE SKY IS BLUE



我的代码是:
#include<stdio.h>
#include<string.h>
int main()
{
     int N,i,j,k;
     char c;
     char code;
     char map;
     char trans;
     char wrong;
     scanf("%d",&N);
     gets(wrong);
     int h=1;
     while(N--)
     {
         gets(code);
         gets(map);
         for(i=0;((c=code)!='\0');i++)
         {
             if(c==' ')trans=' ';
             else {j=code-'A';
             trans=map;}       }
         printf("%d ",h);
         for(i=0;((k=trans<=90)&&(k=trans>=65)||(k=trans==' '));i++)
         printf("%c",trans);
         h++;
         printf("\n");
     }
     return 0;
}


样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱?

zjqylcy 发表于 2011-3-19 22:26

把答案也附上来吗。。。
是不是k是int型?

葉_浅浅 发表于 2011-3-20 16:45

.....................

linmatsas 发表于 2011-3-20 23:27

C………………………………

_我还活着 发表于 2011-4-29 18:56

没有看懂.....

huangliao6252 发表于 2011-5-6 00:49

int h=1;这个定义应该在 scanf("%d",&N);前面。
页: [1]
查看完整版本: 谁来帮忙看一下这个题错在哪里?