描述
给定一个只由大写字母组成的字符串 s,按照字母表的中第 i 个字母变成第 (26 - i + 1) 个字母(如 A 变 Z),变换字符串中的所有字母,通过 System.out.print 语句输出变换后的字符串到标准输出流(控制台)。
样例
评测机会将整个项目的代码编译为一个可执行的 Main 程序,并按照这样的方式执行你的代码 Main。你的代码需要从标准输入流(控制台)中读入数据 s,计算出结果并打印到标准输出流(控制台)中。
样例一
当 s = ZXXVKGVW 时,程序执行打印出的结果为:
ACCEPTED
样例二
当 s = ABC 时,程序执行打印出的结果为:
ZYX
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code here
// read data from console
// output the answer to the console according to the
// requirements of the question
Scanner scanner = new Scanner(System.in);
String str = scanner.next();
char[] chars = str.toCharArray();
for(int i = 0; i < chars.length; i++){
int val = chars[i];
val = 90 -val + 65;
chars[i] = (char)val;
}
System.out.println(String.valueOf(chars));
}
}