'commit'
This commit is contained in:
28
TangDou/XiTi/1119.cpp
Normal file
28
TangDou/XiTi/1119.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user