Re-answer questions from Jilin University -- reverse string code

Source: Internet
Author: User
Tags uppercase character

Question 1105: reverse code of a string


Time Limit: 1 second memory limit: 32 MB Special Judgment: No submitted: 2118 solution: 576


Description:
A binary number, which is called the inverse code of each bit. Next we define a character's anticode. If it is a lowercase character, the distance between it and the character 'a' is the same as its anti-code and the character 'Z'; if it is an uppercase character, the distance between it and the character 'a' is the same as its anti-code and the character 'Z'. If it is not the above two cases, its anti-code is its own.
For example, the backcode of 'A' is 'Z'; The backcode of 'C' is 'x'; The backcode of 'W' is 'D '; '1' or '1'; '$' or '$ '.
The anticode of a string is defined as the anticode of all its characters. Our task is to calculate the inverse code of the given string.


Input:

Each input line is a string of no more than 80 characters. If only !, Indicates that the input is complete and does not need to be processed.


Output:

For each input string, the return code is output, and each data occupies one row.


Sample input:

Hello
JLU-CCST-2011
!
Sample output:
Svool
QOF-XXHG-2011

 
  

Package: answers questions from Jilin University. 1st question _ string reverse code; import Java. io. bufferedinputstream; import Java. util. extends; public class main {/*** @ Param ARGs */public static void main (string [] ARGs) {using CIN = new using (New bufferedinputstream (system. in); string STR = NULL; while (CIN. hasnext () {STR = cin. nextline (); If (Str. equals ("") {continue;} If (Str. compareto ("! ") = 0) {return;} system. out. println (convert (STR) ;}}/*** function: return the "reverse code" of the string ** @ return str_temp */public static string convert (string Str) {string str_temp = ""; char [] A = Str. tochararray (); For (INT I = 0; I <. length; I ++) {If (A [I]> = 'A') & (A [I] <= 'Z ')) {A [I] = (char) ('Z'-(A [I]-'A '));} else if (A [I]> = 'A') & (A [I] <= 'Z') {A [I] = (char) ('Z'-(A [I]-'A');} str_temp + = A [I];} return str_temp ;}}

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.