Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int bitCount(int x)
- {
- int sol = 0;
- for(int i = 0; i < 32; i++)
- if(x & (1 << i)) sol++;
- return sol;
- }
- int main()
- {
- int n;
- cin >> n;
- cout << bitCount(n);
- }
Advertisement
Add Comment
Please, Sign In to add comment