#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int count_one_bit(int n)
{
int count = 0;
while (n)
{
count++;
n = n&(n - 1);
}
return count;
}
int main()
{
int m = 1999;
int n = 0;
int ret = 0;
int tmp = 0;
printf("请输入两个数:");
scanf("%d%d", &m, &n);
tmp=m^n;
ret = count_one_bit(tmp);
printf("%d\n", ret);
return 0;
}
两个int(32位)整数m和n的二进制表达式中,有多少个位不用?
最新推荐文章于 2018-04-08 17:20:41 发布