The hardest problem ever.

Source: Internet
Author: User
Tags strcmp

Julius Caesar住在一个充满危险和阴谋的时代,他遇到的最困难的境遇是让自己存活,为了让自己存活,他决定创建一个以及的秘密文件,此密码文件是一件很令人难以置信的事,在不知道它的工作原理前没人能理解它。你是Caesar军队的一个分队长,你的工作室破译Caesar送来的信息并汇报给你的上级。密码很简单,每个字母对应着一个明文,你将明文向右移五步以得到安全的信息。

Encrypt 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
PlainText 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 the letters in the ciphertext are switched, the non-alphabetic characters should remain unchanged, and all the letters are capitalized.
Input:
The input to this question consists of a series of (non-empty) up to 100 data, each formatted in the following format, and no blank lines are split between the different data. All characters are in uppercase.
A separate test data consists of 3 parts:
(1) Start line: A separate line "start".
(2) Encrypted information line: a single line with 1~200 characters consisting of one line of information from Caesar.
(3) End line: A separate line "ENF".
Finally, the end of a set of test data is followed by a separate line of "Endofinput".
Output:
Each test data will only have one row of output, which is the original text of Caesar.

#include <stdio.h>#include <string.h>intMainvoid){Chara[ -],b[ -];intI while(Gets (a)) {if(strcmpA"START")==0)        {memset(b,0,sizeof(b)); }Else if(strcmpA"END")==0)        {printf('%s ', b); }Else if(strcmpA"Endofinput")==0)        { Break; }Else{ for(i=0; a[i]!=' + '; ++i) {if(a[i]>=' A '&&a[i]<=' Z ') {b[i]= (a[i]-' A '+5)% -+' A '; }            }        }    }return 0;}

or for the input endofinput to end the program, you can end the program by return 0;

elseif(strcmp(a,"ENDOFINPUT")==0){    return0;}

Pass the parameter 0 to the system and tell the system that the program needs to end.
Clever use of return 0;

The hardest problem ever.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.