C++求2進制01不同的位數(shù)
來源:程序員人生 發(fā)布時間:2015-06-06 08:27:28 閱讀次數(shù):3529次
#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;
}
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學習有所幫助,可以手機掃描二維碼進行捐贈