题解 | #记负均正II#

记负均正II

https://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

const lines: number[] = [];

rl.on('line', function (line) {
    lines.push(parseInt(line));
});

rl.on('close', () => {
    let negativeCount = 0;
    let notNegativeTotal = 0;
    lines.forEach((item) => {
        if (item < 0) {
            negativeCount++;
        } else {
            notNegativeTotal += item;
        }
    })
    console.log(negativeCount);
    const ave = notNegativeTotal ? (notNegativeTotal / (lines.length - negativeCount)) : 0;
    console.log(ave.toFixed(1));
})

全部评论

相关推荐

老树开花:可以开始投了,不用等到觉得完全准备好。一边投一边根据面试反馈改简历是最高效的方式。简历上项目描述建议突出你解决的具体问题,比如编辑器的性能优化、大文档渲染怎么处理的,而不只是列技术栈。中厂前端实习现在竞争确实激烈,建议同时关注一些有AI业务的团队,前端加AI应用是很有差异化的组合。Vue全家桶基础扎实的话可以往SSR或者跨端方向延伸,这些是面试加分项。加油,时间还来得及。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务