题解 | #众数#
众数
https://www.nowcoder.com/practice/1549bbe3d8f546f888f4290250d9e2a6
#include <iostream> #include <algorithm> using namespace std; int main(){ int num; int arr[11]={0}; int maxnum = -1; for (int i = 0; i < 20; ++i) { cin>>num; arr[num]++; maxnum = max(maxnum,arr[num]); } for (int i = 1; i <=10 ; ++i) { if (arr[i]==maxnum){ cout<<i<<endl; break; } } }