文章
9
粉丝
0
获赞
29
访问
2.1k
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
map<int, int > mymap;//一号位放 数字,二号位放 次数
for (int i = 0; i < n; i++) {
int b;
cin >> b ;
mymap[b]++;
}
// for (auto value : mymap) {//遍历打印
// cout << value.first << " " << value.second << endl;
// }
for (auto i = mymap.begin(); i != mymap.end(); i++) {//使用auto,迭代器遍历
// cout << i->first << " " << i->second << endl;
if (i->second > n / 2) {//出现次数大于一半的
cout...
登录后发布评论
暂无评论,来抢沙发