fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. int bit_count(int x)
  7.  
  8. {
  9.  
  10. int ret = 0;
  11. if(! x) return 0;
  12. //code
  13. ret += bit_count( (unsigned)x >> 1 );
  14. ret += x & 0x1;
  15.  
  16. return ret;
  17.  
  18. }
  19.  
  20.  
  21. int main() {
  22. // your code goes here
  23.  
  24. printf("%d", bit_count(-1));
  25. return 0;
  26. }
Success #stdin #stdout 0s 4380KB
stdin
Standard input is empty
stdout
32