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 ;}}