import java.util.*;
public class Main {
/题目描述
密码是我们生活中非常重要的东东,我们的那么一点不能说的秘密就全靠它了。哇哈哈. 接下来渊子要在密码之上再加一套密码,虽然简单但也安全。
假设渊子原来一个BBS上的密码为zvbo9441987,为了方便记忆,他通过一种算法把这个密码变换成YUANzhi1987,这个密码是他的名字和出生年份,
怎么忘都忘不了,而且可以明目张胆地放在显眼的地方而不被别人知道真正的密码。他是这么变换的,大家都知道手机上的字母:
1--1, abc--2, def--3, ghi--4, jkl--5, mno--6, pqrs--7, tuv--8 wxyz--9, 0--0,
就这么简单,渊子把密码中出现的小写字母都变成对应的数字,数字和其他的符号都不做变换,
声明:密码中没有空格,而密码中出现的大写字母则变成小写之后往后移一位,
如:X,先变成小写,再往后移一位,不就是y了嘛,简单吧。记住,z往后移是a哦。
输入描述:
输入包括多个测试数据。输入是一个明文,密码长度不超过100个字符,输入直到文件结尾
输出描述:
输出渊子真正的密文
示例1
输入
YUANzhi1987
输出
zvbo9441987/
public static void main(String[] args) {
String[] arr = new String[]{"A","B","C","D","E","F","G",
"H","I","J","K","L","M","N",
"O","P","Q","R","S","T","U",
"V","W","X","Y","Z"};
Obj[] map = new Obj[]{
new Obj("1","1"),//abc--2, def--3, ghi--4, jkl--5, mno--6, pqrs--7, tuv--8 wxyz--9, 0--0,
new Obj("a","2"),new Obj("b","2"),new Obj("c","2"),
new Obj("d","3"),new Obj("e","3"),new Obj("f","3"),
new Obj("g","4"),new Obj("h","4"),new Obj("i","4"),
new Obj("j","5"),new Obj("k","5"),new Obj("l","5"),
new Obj("m","6"),new Obj("n","6"),new Obj("o","6"),
new Obj("p","7"),new Obj("q","7"),new Obj("r","7"),new Obj("s","7"),
new Obj("t","8"),new Obj("u","8"),new Obj("v","8"),
new Obj("w","9"),new Obj("x","9"),new Obj("y","9"),new Obj("z","9"),
new Obj("0","0"),
};
Scanner sc = new Scanner(System.in);
while (sc.hasNext()){
String next = sc.next();
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < next.length(); i++) {
if (Arrays.binarySearch(arr,next.substring(i,i+1))>=0){
int tmpIndex = Arrays.binarySearch(arr, next.substring(i, i + 1));
if (tmpIndex==arr.length-1){
stringBuilder.append(arr[0].toLowerCase());
}else {
stringBuilder.append(arr[tmpIndex+1].toLowerCase());
}
}else {
try {
Integer.parseInt(next.substring(i,i+1));
stringBuilder.append(next.substring(i,i+1));
} catch (NumberFormatException e) {
out:for (int i1 = 0; i1 < map.length; i1++) {
if (next.substring(i,i+1).equals(map[i1].rce)){
stringBuilder.append(map[i1].rtn);
break out;
}
}
}
}
}
System.out.println(stringBuilder.toString());
}
}
}
class Obj{
String rce;
String rtn;
public Obj(String rce,String rtn){
this.rce = rce;
this.rtn = rtn;
}
}