A
#define _crt_secure_no_warnings 1
#include <stdio.h>
#include <math.h>
int main ()
{
int m = 0;
int n = 0;
int i = 0;
int count = 0;
printf ("Please enter two number: \ n");
scanf ("%d%d", &m, &n);
for (i = 0; i < i++)
{if ((
m >> i) & 1) ^ ((n >> i) (& 1))//Let M and N move to the right I bit then respectively and 1 phase again or if is true count++
count++;
printf ("count=%d", count);
System ("pause");
return 0;
}
Two
#define _crt_secure_no_warnings 1
#include <stdio.h>
#include <math.h>
int main ()
{
int u = 0;
int m = 0;
int n = 0;
int count = 0;
printf ("Please enter two number: \ n");
scanf ("%d%d", &m, &n);
u = m^n; M and N xor or while
(U) //equivalent to finding a number; the number of 1 in binary
{
count++;
u = u & (u-1);
}
printf ("count=%d", count);
System ("pause");
return 0;
}
Three
#define _crt_secure_no_warnings 1
#include <stdio.h>
#include <math.h>
int main ()
{
int i = 0;
int m = 0;
int n = 0;
int count = 0;
printf ("Please enter two number: \ n");
scanf ("%d%d", &m, &n);
for (i = 0; i < i++)
{
if ((M & 1)!= (n & 1))
{
count++
}
m = M >> 1;
n = n >> 1;
}
printf ("count=%d", count);
System ("pause");
return 0;
}