ITeye博客

位运算

SwordAndFlame · 2011-08-15 10:40 · 位运算 · 编程语言 · Markdown

统计1的个数

int count(int x)
{
    int res=0;
    while(x){
        res++;
        x&=x-1;
    }
    return res;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。