#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
int m = 0, n = 0, x = 0, y = 0;
int i = 0, count = 0;
printf("请输入m和n:\n");
scanf("%d%d", &m, &n);
for (i = 0; i < 32; i++)
{
x = (m >> i) & 1;
y = (n >> i) & 1;
if (x != y)
count++;
}
printf("m和n有%d个位不同\n", count);
system("pause");
return 0;
}
时间: 2024-12-29 10:46:36