Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main (void) {
  5. int n, max = 0, res = 0, s = 0;
  6. scanf("%d", &n);
  7. int mas[n];
  8. for (int i = 0; i < n; i++) {
  9. scanf("%d", &mas[i]);
  10. }
  11. for (int i = 0; i < n; i++) {
  12. if (max < mas[i]) {
  13. max = mas[i];
  14. }
  15. }
  16. int chast[max + 1];
  17. for (int i = 0; i < max + 1; i++) {
  18. chast[i] = 0;
  19. }
  20. for (int i = 0; i < n; i++) {
  21. chast[mas[i]]++;
  22. }
  23. for (int i = 0; i < max + 1; i++) {
  24. if (s < chast[i]) {
  25. res = i;
  26. s = chast[i];
  27. }
  28. }
  29. printf("%d\n", res);
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement