题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
//A:65 a:97
for(char ch : str.toCharArray()){
int n = (int) ch;
if(n>= 97 && n<=122){
if(n<=111){
System.out.print((n-97)/3 + 2);
}
else if(n<=115){
System.out.print(7);
}
else if(n<=118){
System.out.print(8);
}else{
System.out.print(9);
}
continue;
}
if(n>=65 && n<=90){
if(n == 90){
System.out.print((char)97);
}else{
System.out.print((char)(n+32+1));
}
continue;
}
System.out.print(ch);
}
}
}

查看14道真题和解析
