#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int main()
{
int num1 = 1999;
int num2 = 2299;
int count = 0;
int ret = num1^num2; //比特位不同异或后结果为1
while (ret)
{
ret = ret&(ret - 1);
count++;
} //将异或后的1输出,即有几个比特位不同
printf("%d", count);
system("pause");
return 0;
}
原文地址:https://blog.51cto.com/14239789/2377671
时间: 2024-10-03 23:00:12