#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> int judge(int m) { int count = 0; while (m) { m = m / 2; count++; } return count; } int main() { int a, b; while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 case // 64 位输出请用 printf("%lld") to int count = 0; int w = 0; w=fmax(judge(a),judge(b)); for (int i = 0; i < w; i++) { int x = (a >> i) % 2; int y = (b >> i) % 2; if (x != y) { count++; } } printf("%d\n", count); } return 0; }
小白尝试C语言