前端笔试 本地正确,牛客上错误
代码如下,有没有同学知道什么情况呀
const readline = require('readline')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
})
let now = 0
let a = 0
let b = 0
let flag = a.length > b.length
rl.on('line', function (line) {
now++
if (now === 1) {
a = line.split('')
} else {
b = line.split('')
flag = a.length > b.length
if (a.length === b.length) {
for (let i = 0; i < a.length; i++) {
if (a[i] === b[i]) continue
flag = a[i] > b[i]
break
}
}
let result = ''
while (a.length) {
let tmp = parseInt(a.pop()) - parseInt(b.pop()|| 0)
if (tmp > 0) {
result = result + tmp
} else {
result = tmp + 10 + result
a[a.length - 1]--
}
}
console.log(result)
}
})
#我的实习求职记录#