参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String s = scanner.nextLine(); char []arr = new StringBuilder(s).reverse().toString().toCharArray(); char []res = new char[arr.length]; int i = 0; for(char x: arr) { if(x >= 'a' && x <= 'z' - 3 || x >= 'A' && x <= 'Z' - 3) res[i++] = (char)(x + 3); else if(x >= 'z' - 2 && x <= 'z') res[i++] = (char)('z' - x + 'a'); else if(x >= 'Z' - 2 && x <= 'Z') res[i++] = (char)('Z' - x + 'A'); if(res[i - 1] >= 'a' && res[i - 1] <= 'z') res[i - 1] = (char)('A' + res[i - 1] - 'a'); else if(res[i - 1] >= 'A' && res[i - 1] <= 'Z') res[i - 1] = (char)('a' + res[i - 1] - 'A'); System.out.print(res[i - 1]); } } }
0.0分
4 人评分
Minesweeper (C语言代码)浏览:856 |
C语言训练-排序问题<2> (C++代码)(sort函数)浏览:1722 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:668 |
2006年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:913 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:641 |
简单的a+b (C语言代码)浏览:564 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:703 |
WU-图形输出 (C++代码)浏览:836 |
三角形 (C++代码)记忆化搜索浏览:1318 |
【金明的预算方案】 (C++代码)浏览:997 |