编程之美2.1——求二进制数中1的个数

#include
using namespace std;
#define i1 0xFF
int main()
{
	//扩展1
	//将32位拆分为4个8位,之后采用查表法
	unsigned long a;
	a = 65536;
	int a1 = a&i1;
	a = a>>8;
	int a2 = a&i1;
	a = a>>8;
	int a3 = a&i1;
	a = a>>8;
	int a4 = a&i1;
	//扩展2
	//异或,之后求1的个数
	int A = 10,B=6;
	int c = A^B;
	return 0;
}

你可能感兴趣的:(编程之美,c++)