题解 | #字符串加解密#
字符串加解密
http://www.nowcoder.com/practice/2aa32b378a024755a3f251e75cbf233a
没有花花肠子,直接暴力
借鉴题解区大佬的,写的js版本
function trans(str,b){
let decode="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split('');
let encode="BCDEFGHIJKLMNOPQRSTUVWXYZAbcdefghijklmnopqrstuvwxyza1234567890".split('');
let res='';
if(b){
//加密
res=str.split('').map(char=>encode[decode.indexOf(char)]).join('');
}else{
res=str.split('').map(char=>decode[encode.indexOf(char)]).join('');
}
return res;
}
let str1=readline();
let str2=readline();
console.log(trans(str1,true));
console.log(trans(str2,false));