题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
IO操作比较耗时
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); for (char c : in.next().toCharArray()) { if ('a' <= c && c <= 'r') { c = (char) ((c - 'a') / 3 + '2'); } else if (c == 's') { c = '7'; } else if ('t' <= c && c <= 'v') { c = '8'; } else if ('w' <= c && c <= 'z') { c = '9'; } else if (Character.isUpperCase(c)) { c = (char) ((c - 'A' + 1) % 26 + 'a'); } System.out.print(c); } } }