let line while(line = read_line()){ let nums = line.split(' ') let a = +nums[0] //字符串转数字 let b = +nums[1] console.log(a+b) }
2. A+B(2)
1 2 3 4 5 6 7 8
let t while(t = read_line()){ while(t--){ let line = read_line() let [a,b] = line.split(' ').map(Number) console.log(a+b) } }
3. A+B(4)
1 2 3 4 5 6 7 8 9 10 11
let line while(line = read_line()){ let [n,...nums] = line.split(' ').map(Number) if(n === 0) break let sum = 0 for(let num of nums){ sum + = num } console.log(sum) }