Posted 2022-04-13Updated 2022-07-08Learning-Note-學習筆記a few seconds read (About 49 words)quickBitcount (quickBitcount)quickBitcount 教學與筆記。 說明x &= (x-1) 的功能是消除從右向左遇到的第一個1 123456789101112131415#include <stdio.h>unsigned quickBitcount(unsigned x) { int count = 0; while(x) { x &= (x-1); count++; } return count;}void main() { printf("%d\n", quickBitcount(78)); // 4}quickBitcount (quickBitcount)https://meowlucian.github.io/C/Common/quickBitcount/AuthorMeow LucianPosted on2022-04-13Updated on2022-07-08Licensed under#CodeC