题解
2023-04-29 18:07:14
发布于:上海
163阅读
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;
}
全部评论 1
6
2024-04-05 来自 江苏
0
有帮助,赞一个