CSU1567: Reverse Rot (water question)

Source: Internet
Author: User

CSU1567: Reverse Rot (water question)

1567: Reverse RotTime Limit: 1 Sec Memory Limit: 128 MB
Submit: 150 Solved: 82
[Submit] [Status] [Web Board] Description

A very simplistic scheme, which was used at one time to encode information, is to rotate the characters within an alphabet and rewrite them. ROT13 is the variant in which the characters A-Z are rotated 13 places, and it was a commonly used insecure scheme that attempted to "hide" data in advance applications from the late 1990's and into the early 2000's.

It has been decided by Insecure Inc. to develop a product that "improves" upon this scheme by first reversing the entire string and then rotating it. as an example, if we apply this scheme to string ABCD with a reversal and rotation of 1, after the reversal we wowould have DCBA and then after rotating that by 1 position we have the result EDCB.

Your task is to implement this encoding scheme for strings that contain only capital letters, underscores, and periods. Rotations are to be placed med using the alphabet order:

ABCDEFGHIJKLMNOPQRSTUVWXYZ _.
Note that underscore follows Z, and the period follows the underscore. thus a forward rotation of 1 means 'A' is shifted to 'B', that is, 'A' → 'B', 'B' → 'C ',..., 'Z' → '_', '_' → '. ', and '. '→ 'A '. likewise a rotation of 3 means 'A' → 'D', 'B' → 'E ',..., '. '→ 'C '.

 

Input

Each input line will consist of an integer N, followed by a string. N is the amount of forward rotation, such that 1 ≤ N ≤ 27. the string is the message to be encrypted, and will consist of 1 to 40 characters, using only capital letters, underscores, and periods. the end of the input will be denoted by a final line with only the number 0.

 

Output

For each test case, display the "encrypted" message that results after being reversed and then shifted.

 

Sample Input
1 ABCD3 YO_THERE.1 .DOT14 ROAD9 SHIFTING_AND_ROTATING_IS_NOT_ENCRYPTING2 STRING_TO_BE_CONVERTED1 SNQZDRQDUDQ0
Sample Output
EDCBCHUHKWBR.UPEAROADPWRAYF_LWNHAXWH.RHPWRAJAX_HMWJHPWRAORQ.FGVTGXPQEAGDAQVAIPKTVUREVERSE_ROT
HINT

 

 

 

Source
#include
 
  #include
  
   int main(){    char  str[45],mod[]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ_."},ch;    int n;    while(scanf("%d ",&n)>0&&n)    {        //getchar();        scanf("%s",str);        int len=strlen(str);        for(int i=0,j=len-1;i
   
  
 

Related Article

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.