Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main (void) {
- int n, max = 0, res = 0, s = 0;
- scanf("%d", &n);
- int mas[n];
- for (int i = 0; i < n; i++) {
- scanf("%d", &mas[i]);
- }
- for (int i = 0; i < n; i++) {
- if (max < mas[i]) {
- max = mas[i];
- }
- }
- int chast[max + 1];
- for (int i = 0; i < max + 1; i++) {
- chast[i] = 0;
- }
- for (int i = 0; i < n; i++) {
- chast[mas[i]]++;
- }
- for (int i = 0; i < max + 1; i++) {
- if (s < chast[i]) {
- res = i;
- s = chast[i];
- }
- }
- printf("%d\n", res);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement