Guest User

Untitled

a guest
Nov 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include "stdafx.h"
  2. int BitCounter(int a)
  3. {
  4. int Counter=0;
  5. int CountTime=1;
  6. for(;a;a/=2){
  7. if(a&1){
  8. Counter++;
  9. CountTime++;
  10. }
  11. if(CountTime==12)
  12. break;
  13. }
  14. return Counter;
  15. }
  16. int main()
  17. {
  18. int a;
  19. scanf("%d",&a);
  20. printf("%d",BitCounter(a));
  21.  
  22. return 0;
  23. }
Add Comment
Please, Sign In to add comment