ACM - 1的个数

  怒刷水题。。。

  AC代码:

#include <stdio.h>
int main()
{
    int x,t,count;
    scanf("%d",&t);
    while(t--)
    {
        count=0;
        scanf("%d",&x);
        for(; x!=0;x>>=1)
            count+=(x&1);
        printf("%d\n",count);
    }
	return 0;
}

  

猜你喜欢

转载自www.cnblogs.com/darkchii/p/9164520.html
ACM