题解 | #记负均正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 nativeNum = 0
    let postiveNum = 0
    let postiveTotal = 0
    while(line = await readline()){
        let inputNum = Number(line)
        if (inputNum < 0) {
            nativeNum++
        } else {
            postiveNum++
            postiveTotal+=inputNum
        }
    }
    console.log(nativeNum)
    if (postiveNum > 0) {
        console.log((postiveTotal / postiveNum).toFixed(1))
    } else {
        console.log('0.0')
    }
}()

全部评论

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务