Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. int bitcount(int n) {
  2. unsigned int c1 = 0;
  3. for (; n > 0; n >>= 1)
  4. if (n & 1) {
  5. c1++;
  6. }
  7. return c1;
  8. }
  9.  
  10. int main() {
  11. int a = -2;
  12. printf("%u n", bitcount(a));
  13. return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement