codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
int pop_count (unsigned); int pop_count (unsigned bitstring){ int i; int population_count = 0; for(i=0;i<32;i++){ if (bitstring & 0x1){ population_count ++; } bitstring = bitstring >> 1; } return population_count; } int main () { unsigned input = 0xf3f3; unsigned result = 0; result = pop_count(input); printf("\n population count is %d", result); return 1; }
Private
[
?
]
Run code
Submit