给定一个int 数字,要求计算出int数字对应的二进制中1的个数
示例1
输入
15
输出
4
备注:
int数字大于0
加载中...
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