Advertisement
JuliaPopadowska

zad 2/8 PN - zliczanie 1 bin

Apr 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     unsigned int z;
  7.     int wyn=0;
  8.     scanf("%u",&z);
  9.     while (z!=0)
  10.     {
  11.         if ((z & 1) == 1)
  12.         {
  13.             wyn=wyn+1;
  14.         }
  15.         z >>= 1;
  16.     }
  17.     printf("%d", wyn);
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement