标签:
/* * 191. Number of 1 Bits * 2016-6-6 by Mingyang * 上面那道题目做完以后,下面就稍稍改一下就好啦 */ public int hammingWeight(int n) { int res = 0; for (int i = 0; i < 32; ++i) { if ((n&1)==1) { res++; } n = n >> 1; } return res; }
标签:
原文地址:http://www.cnblogs.com/zmyvszk/p/5569015.html