题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
// 0=48
// A=65
// a=97
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
StringBuilder sb = new StringBuilder();
for(int i = 0;i < str.length();i++) {
char c = str.charAt(i);
int num = c - '0';
if(num>=0 && num<10) {
sb.append(c);
}
if(num>=17 && num<43) {
if(num == 42) {
sb.append('A');
}else {
sb.append((char)(c+33));
}
}
if(num>=49 && num<75) {
if(num>=49 && num<=51) sb.append('2');
if(num>=52 && num<=54) sb.append('3');
if(num>=55 && num<=57) sb.append('4');
if(num>=58 && num<=60) sb.append('5');
if(num>=61 && num<=63) sb.append('6');
if(num>=64 && num<=67) sb.append('7');
if(num>=68 && num<=70) sb.append('8');
if(num>=71 && num<=74) sb.append('9');
}
}
System.out.println(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
// 0=48
// A=65
// a=97
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
StringBuilder sb = new StringBuilder();
for(int i = 0;i < str.length();i++) {
char c = str.charAt(i);
int num = c - '0';
if(num>=0 && num<10) {
sb.append(c);
}
if(num>=17 && num<43) {
if(num == 42) {
sb.append('A');
}else {
sb.append((char)(c+33));
}
}
if(num>=49 && num<75) {
if(num>=49 && num<=51) sb.append('2');
if(num>=52 && num<=54) sb.append('3');
if(num>=55 && num<=57) sb.append('4');
if(num>=58 && num<=60) sb.append('5');
if(num>=61 && num<=63) sb.append('6');
if(num>=64 && num<=67) sb.append('7');
if(num>=68 && num<=70) sb.append('8');
if(num>=71 && num<=74) sb.append('9');
}
}
System.out.println(sb);
}
}