191. Number of 1 Bits

!!!题目地址!!!

int hammingWeight(uint32_t n) {
	int total = 0;
	for (int i = 0; i < 32; i++) {
		total += (n & 1);
		n = n >> 1;
	}
	return total;
}

posted @ 2022-05-18 00:31  ReaIms  阅读(10)  评论(0编辑  收藏  举报