Skip to content

Instantly share code, notes, and snippets.

@ndzj081221130
Created February 17, 2014 10:58
Show Gist options
  • Select an option

  • Save ndzj081221130/9048596 to your computer and use it in GitHub Desktop.

Select an option

Save ndzj081221130/9048596 to your computer and use it in GitHub Desktop.
求二进制中1的个数
> Written with [StackEdit](https://stackedit.io/).
右移,与0x1比较
除2,比较余数
编程之美p121,解法三
while(v){
v &= (v-1);
count++;
}
空间换时间。
case语句,0x0---0xff
查表
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment