fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5. int arr[5] = {1,2,3,4,5};
  6.  
  7. int i,j,bitcounts[8] = {0};
  8.  
  9. for (i = 0; i < 5; ++i){
  10. for (j = 0; j < 8; ++j){
  11. if (arr[i] & (1 << j)){
  12. bitcounts[j]++;
  13. }
  14. }
  15. }
  16.  
  17. printf("%d", bitcounts[2]);
  18.  
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 4576KB
stdin
Standard input is empty
stdout
2