计算9999的二进制中含有多少个1
2013-06-19 11:18
459 查看
// 求数字的二进制含有多少个1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <stdio.h> int func(int num) { int countx = 0; while (num) { countx ++; num = num&(num-1); } return countx; } int _tmain(int argc, _TCHAR* argv[]) { int num=9999; int count=func(9999); printf("%d",count); getchar(); return 0; }
相关文章推荐
- 计算一个数的二进制表示中有多少个1
- gcc __builtin_popcount 计算二进制表示中有多少1
- c语言:输入两个整数m和n,计算需要改变m的二进制表示中的多少位才能得到n
- 计算将一个十进制整数转换成二进制含多少个1
- 输入两个整数m和n,计算需要改变m的二进制表示中的多少位才能得到n。
- C++ 算法之 输入两个整数m n,求计算需要改变m的二进制表示中的多少位才能得到n
- 计算整型数的二进制中包含多少个1
- 计算一个十进制数的二进制表示有多少位1
- 191. Number of 1 Bits (计算一个整数的二进制表示中有多少个1)
- 计算一个数的二进制表示中有多少个1
- 计算一个整数的二进制表示有多少个1(别人的最快算法)
- 计算二进制整数中有多少个1 判断是否为2的n次幂
- 计算一个整数的二进制中有多少个1
- _builtin_popcount()计算二进制中多少个1
- 计算整数二进制中1的最大间隔是多少?
- 如何判断整数x的二进制中含有多少个1
- 编程计算数字二进制中含有1的个数(32位机器为例)
- 算法的强大——快速计算一个正二进制整数中包含多少个1
- 计算二进制中含有1的个数
- 金山招聘题目:编程计算从1到2008080808之间的整数有多少个含有数字7