Advertisement
Josif_tepe

Untitled

Dec 23rd, 2022
1,208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. #include <cstring>
  5. using namespace std;
  6.  
  7. int main() {
  8.     int n;
  9.     cin >> n;
  10.    
  11.     int bitovi = 0;
  12.     while(n > 0) {
  13.         if(n % 2 == 1) {
  14.             bitovi++;
  15.         }
  16.         n /= 2;
  17.     }
  18.     cout << bitovi << endl;
  19.     return 0;
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement