while (n) { ++dist; n &= n - 1; } 其中n为给定数字,dist存放计数值 转载于:https://www.cnblogs.com/zhuangbijingdeboke/p/8431853.html