Hashset内部排序是根据ASCII码进行排序 HashSet的自动取重是根据hashcode 和 equals 进行比较的,而不是直接使用等号,因为对于引用类型的数据来说,等于号比较的是引用之间的地址。
//用set,很简单,会自动去重和排序 #include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int n, num; set<int> a; cin >> n; while(n--){ cin >> num; a.insert(num); } for(set<int>::iterator i = a.begin(); i != a.end();i++){ cout << *...