用数组下标表示输入的数,对应的值表示出现个数
max_element 可以很方便的算出区间最大值
循环数组找到最大值对应的下标
#include <bits/stdc++.h>
using namespace std;
ostream &sp(ostream &output);
int main ()
{
int n;
while(scanf("%d",&n) != EOF)
{
int a[11];
fill(a,a+11,0);//全部置0
a[n]++;
int x;
for(int i = 0; i < 19; ++i)
{
scanf("%d",&x);
a[x]++;
}
auto loc = max_element(a,a+11);
for(int i = 1; i <= 10; ++i)
{
if(a[i] == *loc)
{
cout<<i<<endl;
break;
}
}
}
return 0;
}
ostream &sp(ostream &output)
{
return output << " ";
}