"POJ 3749" Decipher Password _

Source: Internet
Author: User
Tags alphanumeric characters

Description said the earliest cipher came from the Roman Emperor Julius Caesar. Message encryption means that each letter in the original of the message is replaced with the 5th letter after the letter (for example, each letter a in the original message is replaced with the letter F respectively). And you have to get the original message, which is to turn the process back.

Password Letter: 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 M
Original 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

Note: Only letters can be replaced, other non-alphanumeric characters will not be changed, and all letters in the original text of the message are capitalized.

Input is composed of no more than 100 datasets, no empty rows between each dataset, and 3 components per dataset:

Start line: Start password message: A line consisting of 1 to 200 characters representing a message from Caesar. Ending line: End

After the last dataset, is another row: Endofinput

Output each data set corresponds to a row, is Caesar's original message.

Sample Input

Start
ns BFW, jajsyx tk nrutwyfshj fwj ymj wjxzqy tk ywnanfq hfzxjx
end
START
N btzqi WFYMJW the NS F Qnyyqj ngjwnfs anqqflj Ymfs xjhtsi NS wtrj end START ifsljw pstbx kzqq bjqq ymfy hfjxfw
NX rtwj ifsljwtzx S MJ
End
Endofinput

Sample Output

In WAR, EVENTS of importance ARE The result of TRIVIAL causes I WOULD rather LITTLE to be-
A Iberian Village SECOND in ROME DANGER knows full so, CAESAR is more
dangerous THAN he

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main ()
{
	int i;
	string s1,s2;
	Char s[200];
	while (CIN>>S1)
	{
		if (s1== "Endofinput") break
		;
		GetChar ();
		Cin.getline (s,200);
		cin>>s2;
		For (I=0;i<strlen (s); i++)
		{
			if (s[i]>= ' A ' &&s[i]<= ' Z ')
			{
				if (s[i]>= ' F ')
				Cout<<char (s[i]-5);
				else
				Cout<<char (s[i]+21);
			}
			else
			cout<<s[i];
		}
		cout<<endl;
	}
	return 0;
}


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.