求给定数的二进制形式中有多少个1

        static int FOO(int i)
        {
            int count = 0;
            while (i >0)
            {
                i &= i - 1;
                count++;
            }
            return count;
        }

posted on 2010-05-29 19:17  林大虾  阅读(282)  评论(0)    收藏  举报

导航