标签:sign while 运算 turn des 退出 int bsp desc
class Solution { public: int NumberOf1(int n) { int ans=0 ; unsigned int flag = 1 ; while(flag){//flag超出范围之后会是0 if(n&flag)ans++; flag = flag<<1 ; } return ans ; } };
标签:sign while 运算 turn des 退出 int bsp desc
原文地址:https://www.cnblogs.com/Stephen-Jixing/p/13124110.html