#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;
}
本文出自 “零点时光” 博客,请务必保留此出处http://10741764.blog.51cto.com/10731764/1708442
原文:http://10741764.blog.51cto.com/10731764/1708442