首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
计算二进制数中1的个数
[编程题]计算二进制数中1的个数
热度指数:540
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32M,其他语言64M
算法知识视频讲解
给定一个int 数字,要求计算出int数字对应的二进制中1的个数
示例1
输入
15
输出
4
备注:
int数字大于0
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(15)
分享
纠错
提交结果有问题?
4个回答
0篇题解
开通博客
暂无题解
问题信息
阅文集团
2021
Java工程师
来自:
2023届阅文Java...
上传者:
小小
难度:
4条回答
15收藏
2644浏览
热门推荐
通过挑战的用户
尔康不要啊
2023-03-02 14:37:47
在思考的小白很苗条
2023-02-25 22:04:49
GXR1116
2023-02-23 15:58:22
柚Zz皮
2023-02-17 16:06:58
牛客28244...
2023-02-03 12:33:15
相关试题
下列哪两个变量之间的相关程度高
数据分析师
途虎
2021
评论
(4)
来自
途虎养车2023秋招数据...
五月份的商品销售额为60万元,该月...
数据分析师
途虎
2021
评论
(2)
来自
途虎养车2023秋招数据...
开启两个线程A、B,打印1到10,...
Java工程师
阅文集团
2021
评论
(12)
来自
2023届阅文Java方...
请简要说明Servlet中的生命周期
Java工程师
阅文集团
2021
评论
(6)
来自
2023届阅文Java方...
数据多项排序
Java工程师
阅文集团
2021
评论
(3)
来自
2023届阅文Java方...
计算二进制数中1的个数
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 计算int对应二进制中1的个数 * @param n int整型 数字 * @return int整型 */ public int countBit (int n) { // write code here } }
class Solution { public: /** * 计算int对应二进制中1的个数 * @param n int整型 数字 * @return int整型 */ int countBit(int n) { // write code here } };
# # 计算int对应二进制中1的个数 # @param n int整型 数字 # @return int整型 # class Solution: def countBit(self , n ): # write code here
/** * 计算int对应二进制中1的个数 * @param n int整型 数字 * @return int整型 */ function countBit( n ) { // write code here } module.exports = { countBit : countBit };
# # 计算int对应二进制中1的个数 # @param n int整型 数字 # @return int整型 # class Solution: def countBit(self , n ): # write code here
package main /** * 计算int对应二进制中1的个数 * @param n int整型 数字 * @return int整型 */ func countBit( n int ) int { // write code here }
/** * 计算int对应二进制中1的个数 * @param n int整型 数字 * @return int整型 */ int countBit(int n ) { // write code here }
15
4