Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
298 B
0
Indexable
Never
#include <iostream>
using namespace std;

int count(unsigned int n) {
    int count = 0;
    while (n > 0) {
        if (n & 1) {
            count++;
        }
        n = n >> 1;
    }
    return count;
}

int main() {
    unsigned int n;
    cin >> n;
    cout << count(n);
}
Leave a Comment