输入描述:
一行中给定两个数字
输出描述:
输出这两个数字中bit不同的个数
示例:
输入:15 8
输出:3
代码:
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
int n = sc.nextInt();
int count = 0;
int ret = m^n;//0111
while (ret !=0){
int i = ret&1 ;
ret = ret / 2;
if(i == 1) {
count++;
}
System.out.println(count);
}
}