找出众数 题解:
P2014
发布于2026年1月25日 00:18
阅读数 23
#include<iostream>
#include<map>
using namespace std;
int n;
map<int,int> s;
int main()
{
int x;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>x;
s[x]++;
}
for(auto it:s)
if(it.second>n/2)
cout<<it.first<<endl;
return 0;
登录后发布评论
暂无评论,来抢沙发