题解
2025-07-27 14:34:31
发布于:浙江
5阅读
0回复
0点赞
真的超简单,感觉配不上黄题
不过最开始粗心了,没注意还要输出个数
#include <bits/stdc++.h>
using namespace std;
int main() {
map<int, int> m;
int n, a[105];
cin >> n;
int tmp = n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
m[a[i]]++;
if (m[a[i]] > 1) {
tmp--;
m[a[i]]--;
}
}
sort (a + 1, a + n + 1);
cout << tmp << endl;
for (int i = 1; i <= n; i++) if (a[i] != a[i - 1]) cout << a[i] << " ";
}
这里空空如也
有帮助,赞一个