题解 | #记负均正II#
记负均正II
https://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { // Write your code here let num = 0; let sum = 0; let n = 0; let average = 0; while(line = await readline()){ let number = parseInt(line); if(number<0) num++; else { sum+=number; n++; } } if(n===0)average=0; else average=sum/n; console.log(num); console.log(average.toFixed(1)); }()