题解 | #两个整数二进制位不同个数#
两个整数二进制位不同个数
http://www.nowcoder.com/questionTerminal/9c3b8a8d9f1c4ae3b709d04625586225
#include <stdio.h>
int main()
{
int a = 0;
int b = 0;
scanf("%d %d", &a, &b);
int cnt = 0;
int c = a ^ b;
for (int i = 0; i < 32; i++)
{
if (c & 1)
{
cnt++;
}
c >>= 1;
}
printf("%d\n", cnt);
return 0;
}