求出一个正整数转换成二进制后的数字“1”的个数。 例:数字23转为二进制为 10111,其中1的个数为4
示例1
输入
23
输出
4
加载中...
import java.util.*; public class Solution { /** * * @param num int整型 * @return int整型 */ public int trueBitCount (int num) { // write code here } }
class Solution { public: /** * * @param num int整型 * @return int整型 */ int trueBitCount(int num) { // write code here } };
# # # @param num int整型 # @return int整型 # class Solution: def trueBitCount(self , num ): # write code here
/** * * @param num int整型 * @return int整型 */ function trueBitCount( num ) { // write code here } module.exports = { trueBitCount : trueBitCount };
# # # @param num int整型 # @return int整型 # class Solution: def trueBitCount(self , num ): # write code here
package main /** * * @param num int整型 * @return int整型 */ func trueBitCount( num int ) int { // write code here }
/** * * @param num int整型 * @return int整型 */ int trueBitCount(int num ) { // write code here }
23
4