美团前端笔试编程题
很蛋疼的系统,差点被输出搞死。。。
第一题:
var n = parseInt(read_line()) var obj = {} for (var i = 0; i < n; i++) { var key = read_line() obj[key] = 0 } var m = parseInt(read_line()) for (var i = 0; i < m; i++) { var key = read_line() obj[key]++ } var res = [] for (var i in obj) { if (obj[i] == 0) { res.push(i) } } res.sort() for (var i = 0; i < res.length; i++) { if (i == res.length - 1) { printsth(res[i]) } else { print(res[i]) } }
第二题:
var n1 = parseInt(read_line()) var n2 = parseInt(read_line()) if (n1 < n2) { if (n2 - n1 < (360 - n2 + n1)) { printsth(n2 - n1) } else if (n2 - n1 > (360 - n2 + n1)) { printsth(-(360 - n2 + n1)) } else { printsth(Math.abs(n2 - n1)) } } else if (n1 > n2) { if (n1 - n2 > (360 - n1 + n2)) { printsth(360 - n1 + n2) } else if (n1 - n2 < (360 - n1 + n2)) { printsth(-(n1 - n2)) } else { printsth(Math.abs(n1 - n2)) } } else { printsth(0) }#美团#