Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int mostOccurring(int *arr, int n, int *countPtr);
  4.  
  5. int mostOccurring(int *arr, int n, int *countPtr)
  6. {
  7. int count[10] = { 0 }, i, max;
  8. for (i = 0; i < n; i++)
  9. count[arr[i]]++;
  10. max = 0;
  11. *countPtr = count[0];
  12. for (i = 1; i < 10; i++)
  13. if (count[i] > count[max]) {
  14. max = i;
  15. *countPtr = count[max];
  16. }
  17. return max;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement