bitscount函数的重写

来源:互联网 发布:linux 标准输出重定向 编辑:程序博客网 时间:2024/06/05 11:34
#include <stdio.h>#include <stdlib.h>int main(){    int bitscount(unsigned x);    printf("%d",bitscount(252));    return 0;}//可参照bitDelete函数(将无符号整形数最右边为1的一位删除),在上一//篇博文有讲解int bitscount(unsigned x){    int n = 0;    while(x != 0)    {         x &= (x - 1) ;         n ++;    }    return n;}
0 0
原创粉丝点击