while (n) 
{
         ++dist;
         n &= n - 1;
}

其中n为给定数字,dist存放计数值

posted on 2018-02-08 15:46  高数考了59  阅读(149)  评论(0编辑  收藏  举报