文章
34
粉丝
18
获赞
6
访问
14.5k
#include <iostream>
#include <map>
using namespace std;
int main(){
map<int,int> mymap;
int n,m;
cin >> n;
m = n;
while(n --){
int t;
cin >> t;
mymap[t] ++;
}
map<int,int>::iterator it;
for(it = mymap.begin();it != mymap.end();it ++){
if(it->second > m / 2){
cout << it->second << endl;
}
}
return 0;
}
#include <iostream>
#include <string.h>
using namespace std;
const int N = 1e5 + 10;
int main(){
int n;
int a[N],b[N];
memset(b,0,sizeof(b));
cin >> n;
for(int i = 0;i < n;i ++){
cin >> a[i];
b[a[i]] ++;
}
for(int i = 0;i < n;i ++){
if(b[a[i]] > n / 2){
cout << a[i] << endl;
b[a[i]] = 0;
}
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发