题解 | #简单密码# 大道至简
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
模拟
import java.io.*; import java.util.*; public class Main { static final int[] map = { 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9}; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); String str = br.readLine(); pw.println(transform(str)); pw.flush(); pw.close(); br.close(); } private static String transform(String str) { StringBuilder builder = new StringBuilder(); for (char c : str.toCharArray()) { if (Character.isUpperCase(c)) { c = Character.toLowerCase(c); c = (char) ((c - 'a' + 1) % 26 + 'a'); builder.append(c); } else if (Character.isLowerCase(c)) { builder.append(map[c - 'a']); } else { builder.append(c); } } return builder.toString(); } }