#include <bits/stdc++.h> using namespace std; int main() { int n; set<int> ans; cin >> n; while(cin >> n) ans.emplace(n); for(auto &i:ans) cout << i << endl; } // 64 位输出请用 printf("%lld")
通过 set 自动去重以及排序功能,逐个读入即可。
#include <bits/stdc++.h> using namespace std; int main() { int n; set<int> ans; cin >> n; while(cin >> n) ans.emplace(n); for(auto &i:ans) cout << i << endl; } // 64 位输出请用 printf("%lld")
通过 set 自动去重以及排序功能,逐个读入即可。