题解
【入门】找出数列元素唯一并排序
1 条题解
-
0
#include <iostream> #include <set> using namespace std; int main() { int n; cin >> n; set<int> s; for (int i = 0; i < n; i++) { int x; cin >> x; s.insert(x); } // set 本身就是有序的,直接输出 for (auto it = s.begin(); it != s.end(); ++it) { if (it != s.begin()) { cout << " "; } cout << *it; } cout << endl; return 0; }
- 1