题解
2024-03-17 19:40:01
发布于:河北
1阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int array[n];
int tmp = 0;
int count = 0;
for (int i = 0; i < n; ++i) {
cin >> array[i];
}
for (int j = 0; j < n; ++j) {
for (int k = 0; k < n; ++k) {
if (array[j] == array[k]) {
++count;
}
}
if (count > n / 2) {
if (array[j] != tmp) {
cout << array[j] << " ";
}
tmp = array[j];
}
count = 0;
}
return 0;
}
这里空空如也
有帮助,赞一个