代码如下:
public class App {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
char[] characters = {
'Z', 'Y', 'X', 'W', 'V', 'U', 'T', 'S', 'R',
'Q', 'P', 'O', 'N', 'M', 'L', 'K', 'J', 'I',
'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A'
};
String s = scanner.nextLine();
String s2 = "";
for (char ch : s.toCharArray()) {
if (Character.isUpperCase(ch)) {
s2 += characters[ch - 'A'];
} else {
s2 += ch;
}
}
System.out.println(s2);
}
}
运行结果: