编程之美 [编程之美_2.1]求二进制中1的个数 1 2 3 4 5 6 7 8 9 10 int CountOne(int val) { int cnt = 0; while (val) { val &= val - 1; cnt++; } return cnt; }