fork download
  1. #include <stdio.h>
  2.  
  3. void hist(unsigned char x[], int r, unsigned int h[])
  4. {
  5. for(int j=0; j<40; j++)
  6. {
  7. for(int i = 0; i<14; i++)
  8. {
  9. if(x[i]==j)
  10. {
  11. h[j]++;
  12. }
  13. }
  14. }
  15.  
  16. for(int i=0; i<40; i++)
  17. {
  18. printf("%d ", h[i]);
  19. }
  20. }
  21.  
  22. int main()
  23. {
  24. unsigned char x[14] = {4, 2, 33, 29, 32, 11, 43, 1, 4, 10, 12, 12, 32, 4};
  25. unsigned int h[40]={0};
  26. hist(x, 14, h);
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5600KB
stdin
Standard input is empty
stdout
0 1 1 0 3 0 0 0 0 0 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 2 1 0 0 0 0 0 0