#include #include using namespace std; template void print(const set &s) { for (typename set::const_iterator it = s.begin(); it != s.end(); ++it) cout << *it << ' '; cout << endl; } template void print(const multiset &s) { for (typename multiset::const_iterator it = s.begin(); it != s.end(); ++it) cout << *it << ' '; cout << endl; } int main() { int m[] = {1, 2, 3, 2, 3, 4}; set s(m, m + 6); print(s); // set 会自动去重,输出 1 2 3 4 multiset ms(m, m + 6); print(ms); // multiset 不会自动去重,输出 1 2 2 3 3 4 return 0; }