0547就職戦線異状名無しさん
2020/06/26(金) 11:26:52.26ID:9GHNkMv0unsigned int countBits(int bits, int mask){
unsigned int n=0;
register int i;
for( i=1; i&mask; i<<=1 ) if(i&bits) n++;
return n;
}
int main(void){
printf( "%d\n", countBits(0b10101111, 0b11111111) );
return 0;
}
じゃあこれで良いんじゃね?