Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- int BitCounter(int a)
- {
- int Counter=0;
- int CountTime=1;
- for(;a;a/=2){
- if(a&1){
- Counter++;
- CountTime++;
- }
- if(CountTime==12)
- break;
- }
- return Counter;
- }
- int main()
- {
- int a;
- scanf("%d",&a);
- printf("%d",BitCounter(a));
- return 0;
- }
Add Comment
Please, Sign In to add comment