Advertisement
NoxScourge

Untitled

Sep 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void main() {
  4.  
  5.  
  6. int broj, br1 = 0;
  7. int n, i, a[200], cifra, m, j;
  8.  
  9. printf("Unesite koliko brojeve zelite da unesete=");
  10.  
  11. scanf("%d", &n);
  12.  
  13. for (i = 0;i < n;i++) {
  14.  
  15. scanf("%d", &broj);
  16.  
  17. while (broj > 0) {
  18.  
  19.  
  20. if (broj % 2 == 0) {
  21.  
  22.  
  23. cifra = 0;
  24. broj = broj / 2;
  25. }
  26.  
  27. else {
  28. cifra = 1;
  29. broj = broj / 2;
  30. br1++;
  31.  
  32. }
  33. }
  34. }
  35.  
  36. printf("broj jedinica = %d", br1);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement