码迷,mamicode.com
首页 > 编程语言 > 详细

C++求2进制01不同的位数

时间:2015-05-01 10:42:25      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

#include <iostream>
using namespace std;
int Grial(int x,int y)
{
	int count  = 0;
	while(x!=0 || y!=0)
	{
		if( ((x&0x1) ^ (y&0x1)) )
		count++;
		x>>=1;
		y>>=1;
	}
	return count;
}
int main()
{
	cout<<Grial(2,15)<<endl;
	return 0;
}

C++求2进制01不同的位数

标签:

原文地址:http://blog.csdn.net/liuhuiyan_2014/article/details/45418073

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!