码迷,mamicode.com
首页 > 其他好文 > 详细

Bailian2975 Caesar Cryptogram

时间:2018-11-20 01:15:04      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:while   star   nes   结束   lan   eve   ble   nan   sla   

2975:Caesar Cryptogram
描述
Julius Caesar inventes a cryptogram that converts a string to another
string. The rule is that every letter in an original string should be replaced
by the letter which takes the fifth place after it in the alphabet. The
conversion table is as follows:

Original string: 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
Encrypted string: 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

All letters in original strings are capital. The characters other than
letters remain the same.

输入
There are no more than 100 datasets. Each dataset consists of three lines.

Starting line: START

Encrypted string: containing 1 to 200 characters

Ending line: END
输出
For every dataset, output one line, the original string.
样例输入
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

问题链接Bailian2975 Caesar Cryptogram
问题描述:(略)
问题分析
????这个问题与参考链接是同一题,这里就不解释了。
程序说明:(略)
参考链接HDU1048 POJ1298 ZOJ1392 UVALive2540 The Hardest Problem Ever【密码+水题】
题记:(略)

AC的C语言程序如下:


/* HDU1048 The Hardest Problem Ever(简洁版) */

#include <stdio.h>
#include <string.h>

char start[]= "START";
char end[]= "END";
char endofinput[]= "ENDOFINPUT";
char cipher[] = "VWXYZABCDEFGHIJKLMNOPQRSTU";

int main(void)
{
    char s[1024], *p;

    for(;;) {
        gets(s);

        // 判断开始:START
        if(strcmp(s, start) == 0)
            continue;

        // 判断报文结束:END
        if(strcmp(s, end) == 0)
            continue;

        // 判断结束:ENDOFINPUT
        if(strcmp(s, endofinput) == 0)
            break;

        // 译码
        p = s;
        while(*p) {
            if('A' <= *p && *p <='Z') {
                *p = cipher[*p - 'A'];
            }
            p++;
        }

        // 输出结果
        printf("%s\n", s);
    }

    return 0;
}

Bailian2975 Caesar Cryptogram

标签:while   star   nes   结束   lan   eve   ble   nan   sla   

原文地址:https://www.cnblogs.com/tigerisland45/p/9986756.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!