题解 | #查找输入整数二进制中1的个数#

查找输入整数二进制中1的个数

https://www.nowcoder.com/practice/1b46eb4cf3fa49b9965ac3c2c1caf5ad

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
// let arr = []
rl.on('line', function (line) {
    console.log(parseInt(line).toString(2).split('1').length - 1)
    // arr.push(parseInt(line).toString(2))
});
// rl.on('close', () => {
//     arr.forEach(item => {
//         console.log(item.split('1').length - 1)
//     })
// })

全部评论

相关推荐

牛客49269852...:这家公司纯神人公司来的,约的我今早11点线下面试,我人都到了,10点和我说改线上,无敌
找实习记录
点赞 评论 收藏
分享
03-01 19:30
已编辑
南京大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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