You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
580 B

#include <bits/stdc++.h>
using namespace std;
//map排序(key)的比较器
struct cmpFunction {
bool operator()(const int &k1, const int &k2) const {
return k1 < k2;
}
};
int main() {
int n;
cin >> n;
map<int, int, cmpFunction> _map;
for (int i = 0; i < n; ++i) {
int c;
cin >> c;
_map[c]++;
}
//输出结果
cout << _map.size() << endl;
for (map<int, int>::iterator iter = _map.begin(); iter != _map.end(); ++iter) {
cout << iter->first << " ";
}
return 0;
}