题解 | #简单密码#需要注意的点有两个一个是大写字母转小写,后退一位,其次就是小写字母转数字
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args) throws Exception{
/*
zvbo9441987
YUANzhi1987
z怎么往后推为a z%26 + 1
*/
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str;
while((str = bf.readLine()) != null){
System.out.print(exchange(str));
}
}
public static String exchange(String password){
StringBuffer sb = new StringBuffer();
for(char c:password.toCharArray()){
if(c <= 'Z' && c >= 'A'){
sb.append("" + (char)((c - 'A' + 1) % 26 + 'a'));
}else if(c <= '9' && c >= '0'){
sb.append(c);
}else{
if(c <= 'c'){
sb.append(2);
}else if(c <= 'f'){
sb.append(3);
}else if(c <= 'i'){
sb.append(4);
}else if(c <= 'l'){
sb.append(5);
}else if(c <= 'o'){
sb.append(6);
}else if(c <= 's'){
sb.append(7);
}else if(c <= 'v'){
sb.append(8);
}else{
sb.append(9);
}
}
}
return sb.toString();
}
}