求两个数的不同位有多少个
2016-08-30 16:29
267 查看
int countBitDiff(int m, int n) { int c; c = m^n; int count = 0; while(c>0) { if(c%2==1) count++; c=c>>1; } return count; }
相关文章推荐
- 求两个数的二进制数的对应位有多少位不同?
- 求两个数之间有多少个比特位不同
- 求两个数的二进制中有多少个不同的bit位
- 给定两个数(A,B),求他们的二进制中多少位(bit)不同?
- 【位运算】求两个数的二进制有多少位不同
- POJ2002 &&HDU5365 判断给定的点中有多少个不同的正方形
- GC是如何工作的,不同的代的大小是多少
- 假设有一个梯子,梯子有n层,每次可以爬1层或者2层,求有多少不同的爬梯方式
- 【C语言】【笔试题】两个int(32位)整数m和n的二进制表达中,有多少个位(bit)不同
- 给定两个正整数(二进制形式表示)A和B,问把A变为B需要改变多少位(bit)?也就是说,整数A和B的二进制表示中有多少位是不同的?
- 在西安,程序员的平均薪资是多少?同职场经验的不同职位薪资差距到底有多大?
- 2015小米实习生笔试题1 求两个数的不同位的个数
- Java 欧拉工程 第二十九篇【a的b次方(2≤a,b≤100)中共有多少个不同的数】
- hdu 5671 String(求有多少个子串,包含有至少k(1≤k≤26)个不同的字母)
- 计算两个数的不同比特位
- POJ 1611 The Suspects 并查集 (统计不同一个树的其他树有多少个)
- C 统计两个数相应的不同位(bit)
- 问题五十七: 楼梯有n阶台阶,上楼可以一步上1阶,也可以一步上2阶,编程序计算共有多少种不同的走法?
- 网易面试题之 牛牛想尝试一些新的料理,每个料理需要一些不同的材料,问完成所有的料理需要准备多少种不同的材料。
- 两个int(32位)整数m和n的二进制表达中,有多少个位(bit)不同?