Untitled
unknown
plain_text
3 years ago
301 B
9
Indexable
#include <iostream>
#include <string>
using namespace std;
int main() {
int a, n, d;
n = 0;
string c;
cin >> a;
d = a;
while (true){
if (d == 1) {
c += to_string(d % 2);
n += 1;
break;
}
c += to_string(d%2);
if (d % 2 == 1) n += 1;
d /= 2;
}
cout << n;
}Editor is loading...