Untitled
unknown
c_cpp
2 years ago
298 B
7
Indexable
#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);
}
Editor is loading...
Leave a Comment