标题:一道题目急需大家帮忙 !!
取消只看楼主
狮子
Rank: 2
等 级:论坛游民
帖 子:25
专家分:13
注 册:2009-5-23
结帖率:100%
已结贴  问题点数:50 回复次数:5 
一道题目急需大家帮忙 !!
题目是全英的,大概意思是将一行字符串加密
Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sound, that no one could figure it out without knowing how it worked.
You are a sub captain of Caesar's army. It is your job to decipher the messages sent by Caesar and provide to your general. The code is simple. For each letter in a plaintext message, you shift it five places to the right to create the secure message (i.e., if the letter is 'A', the cipher text would be 'F'). Since you are creating plain text out of Caesar's messages, you will do the opposite:

Cipher text
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Plain text
V W X Y Z A B C D E F G H I J K L M N O P Q R S T U

Only letters are shifted in this cipher. Any non-alphabetical character should remain the same, and all alphabetical characters will be upper case.
如果输入以下内容:
START
NS BFW, JAJSYX TK NRUTWYFSHJ FWJ YMJ WJXZQY TK YWNANFQ HFZXJX
END
START
N BTZQI WFYMJW GJ KNWXY NS F QNYYQJ NGJWNFS ANQQFLJ YMFS XJHTSI NS WTRJ
END
START
IFSLJW PSTBX KZQQ BJQQ YMFY HFJXFW NX RTWJ IFSLJWTZX YMFS MJ
END
ENDOFINPUT
就有以下输出显示:
IN WAR, EVENTS OF IMPORTANCE ARE THE RESULT OF TRIVIAL CAUSES
I WOULD RATHER BE FIRST IN A LITTLE IBERIAN VILLAGE THAN SECOND IN ROME
DANGER KNOWS FULL WELL THAT CAESAR IS MORE DANGEROUS THAN HE
 各位高手帮帮忙吧~~
搜索更多相关主题的帖子: one situation general captain 
2009-07-21 15:11
狮子
Rank: 2
等 级:论坛游民
帖 子:25
专家分:13
注 册:2009-5-23
得分:0 
我自己的程序,大家看看行不行~~
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main()
{
    char star[11],end[11],meg[100];
    int i;
    do
    {
        
        gets(star);
        if(strcmp(star,"ENDOFINPUT")==0)
            break;
        gets(meg);
        gets(end);
        for(i=0;i<strlen(meg);i++)
        {
            if(meg[i]>='A'&&meg[i]<='E')
                printf("%c",(90-4+(meg[i]-'A')));
            else if(meg[i]>='F'&&meg[i]<='Z')
                printf("%c",meg[i]-5);
            else printf("%c",meg[i]);
            
        }
        printf("\n");
        
        
    }while(1);
    return 0;
}
2009-07-21 19:35
狮子
Rank: 2
等 级:论坛游民
帖 子:25
专家分:13
注 册:2009-5-23
得分:0 
do-while 很好用的哦~
2009-07-22 15:18
狮子
Rank: 2
等 级:论坛游民
帖 子:25
专家分:13
注 册:2009-5-23
得分:0 
回复 4楼 prankmoon
很好啊~不过题目说是当输入ENDOFINPUT时就结束循环哦,所以好像不符合要求哦~
不过~真的很好啦!(*^__^*) 嘻嘻……
2009-07-22 15:25
狮子
Rank: 2
等 级:论坛游民
帖 子:25
专家分:13
注 册:2009-5-23
得分:0 
回复 10楼 NoSoul
good!!
2009-07-22 19:30
狮子
Rank: 2
等 级:论坛游民
帖 子:25
专家分:13
注 册:2009-5-23
得分:0 
回复 12楼 nuciewth
我在杭电里找到的
2009-07-22 23:48



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-280043-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.056379 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved