In the expressions of two integers m and n, how many bits are different

#include<stdio.h>
#include<stdlib.h>
intmain()
{
	int m,n;
	int count=0;
	int tmp=0;
	printf("Please enter two arbitrary integers:\n");
	scanf("%d %d",&m,&n);
	tmp=n^m;
	while(tmp)
	{
		count++;
		tmp=tmp&(tmp-1);
	}
	printf("count=%d\n",count);
	system("pause");
	return 0;

operation result


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325840407&siteId=291194637