Title:
Password letter: ABCDEFGHIJKLMNOPQRSTU VWXYZ
original letter: VWXYZABCDEFGHIJKLMNOP QRSTU
analysis:
By the title of "Password letters" and "the original letter" analysis available, it can be divided into the following letter to "E" and "F" for the cut-off point
The situation is as follows:
Password letter: ABCDE FGH IJKLMNOPQRSTUVWXYZ
Original letters: VWXYZ A BCDEFGHIJKLMNOPQRST U
Analysis can be obtained, prior to the E "Password letters" available 5 Save "original letters used herein," a "password letter" plus 21 available "herein original letter" E after
Thus code is as follows:
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner ( System.in );
while (sc.hasNext ( )) {
String value = sc.nextLine ( );
//将字符串转换为字符数组,以便调用字符
char[] chars = value.toCharArray ( );
for (int i = 0; i < chars.length; i++) {
char c = chars[i];
if ('A' <= c ) {
//核心代码,进行大小写的转换
c = (char) ( 'E' < c ? ( c - 5 ) : ( c + 21 ) );
chars[i] = c;
}
}
System.out.println ( new String ( chars ) );
}
}
}