众数问题

xiaoxiao2025-05-19  34

#include <bits/stdc++.h> using namespace std; #define LL long long map<LL,LL> ma; const int M=1e5+10; int main() { LL n,a,b=0; cin >>n; while(n--) { cin >> a; ma[a]++; b=max(ma[a],b); } map <LL, LL>::iterator t; int f=0; for ( t = ma.begin( ); t != ma.end( ); t++ ) { if(t->second==b) { if(f!=0) { cout << " "; } else { f++; } cout << t->first ; } } cout << endl; cout << b <<endl;; return 0; }

 

转载请注明原文地址: https://www.6miu.com/read-5030334.html

最新回复(0)