add bitmap

This commit is contained in:
nonstriater
2015-12-05 00:55:44 +08:00
parent 168d7ca6d1
commit 0f309ff798
10 changed files with 614 additions and 335 deletions
@@ -0,0 +1,18 @@
#include "stdio.h"
int one_appear_count_by_binary(int num){
int count = 0;
while(num !=0 ){
num &= num-1;
count++;
}
return count;
}
int main(int argc, char const *argv[])
{
int test = 10;
printf("%d\n", one_appear_count_by_binary(test));
printf("%d\n", one_appear_count_by_binary(32+1));
return 0;
}