Anonymous Anonymous - 20 days ago
911 0

No description

C++

modus

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int a, b[100001], max, num, count = 0;
    cin >> a;

    for (int i = 0; i < a; i++)
    {
        scanf("%d", &b[i]);
    }

    sort(b, b + a);
    num = b[0];
    max = 1;

    for (int i = 1; i < a; i++)
    {
        if (b[i] == b[i - 1])
        {
            count++;
        }
        else
        {
            if (count > max)
            {
                max = count;
                num = b[i - 1];
            }
            count = 1;
        }
    }

    if (count > max)
    {
        max = count;
        num = b[a - 1];
    }

    cout << num << "\n";

    return 0;
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download