新方法
class Solution { public: int NumberOf1(int n) { int res=0; while(n){ n&=n-1;//自动去掉最低的1 res++; } return res; } };