#include <stdio.h> int main() { int n=0,m=0,c=0,count=0; scanf("%d %d",&n,&m); c=n^m;//二进制用^可以达到同0异1的效果。n与m不同位上就放了1. //然后统计有多少个1就OK了。 while(c) { count++; c=c&(c-1); } printf("%d",count); return 0; }