首页 > 其他分享 >求2进制中不同位的个数

求2进制中不同位的个数

时间:2023-03-07 17:31:51浏览次数:22  
标签:count 进制 num2 int 不同 个数 differe num num1

#include<stdio.h>
int differe(int num1, int num2) {
int num = num1 ^ num2;
int count = 0;
while (num) {
num = num & num - 1;
count++;
}
}
int main() {
int a = 0;
int b = 0;
scanf_s("%d%d", &a, &b);
int count = differe(a, b);
printf("%d", count);
return 0;
}

标签:count,进制,num2,int,不同,个数,differe,num,num1
From: https://blog.51cto.com/u_13606048/6106364

相关文章