首页 > 试题广场 >

两个整数二进制位不同个数

[编程题]两个整数二进制位不同个数
  • 热度指数:8315 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
输入两个整数,求两个整数二进制格式有多少个位不同

输入描述:
两个整数


输出描述:
二进制不同位的个数
示例1

输入

22 33

输出

5
头像 准备进厂的小熊猫
发表于 2023-09-07 16:13:55
#include <stdio.h> int main() { int a, b; int count=0; while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 c 展开全文
头像 牛客401826932号
发表于 2024-08-02 18:07:57
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> int judge(int m) { int count = 0; while (m) { m = m / 展开全文
头像 牛客497079527号
发表于 2023-11-19 00:05:41
#include <stdio.h> int main() { int n,m; scanf("%d %d", &n,&m); int i = 0; int num = 0; int arr1[32] = { 0 }; int arr2 [ 展开全文
头像 诗云panther
发表于 2021-08-19 19:51:09
include<bits/stdc++.h> using namespace std;class solution {public: string sortstr(string str) { string str1 = "";//存放1-9数 展开全文
头像 小眼神
发表于 2024-01-31 19:08:49
#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不同位上就放 展开全文
头像 给你点了个赞的小哥哥很爱吃肉
发表于 2024-11-02 14:32:06
#include <stdio.h> int main() { int i = 0; int j = 0; int count = 0; scanf("%d %d",&i,&j); int tom =i^j; 展开全文
头像 愿offer多多的小山竹很强大
发表于 2024-02-23 19:50:43
#include <stdio.h> int main() { int a, b; while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 case // 64 展开全文
头像 桃花不换美人
发表于 2023-12-07 13:49:53
#include <stdio.h> int CountDifferentBit(int num1, int num2) { int i = 0; int n = 0; int b = num1^num2; for(i=0;i<32;i++) 展开全文
头像 辛格singe
发表于 2024-02-21 21:04:48
#include <stdio.h> int main() { int a, b; while (scanf("%d %d", &a, &b) != EOF) { int c = 0; f 展开全文
头像 JY0
发表于 2024-05-15 21:20:02
#include <stdio.h> int main() { int a = 0; int b = 0; scanf("%d%d",&a,&b); int c = a ^ b; int count = 0; 展开全文