#include #include //也是set using namespace std; class compare{ public: template bool operator()(const T& a, const T& b){ return a > b; } }; int main(){ auto cmpl = [](auto a, auto b){ return a < b; }; multiset a{1,1,2,3,3,3,4,5,6,7,7,7,10}; multiset b(cmpl); b.insert({14,16,20,18,2,2,2,4,4,6,6,8,8,10,12}); multiset c{1,3,5,7,9,11,11,11,13}; for(int x : a){ cout << x << " "; }cout << endl; for(int x : b){ cout << x << " "; }cout << endl; for(int x : c){ cout << x << " "; }cout << endl; cout << b.count(2) << endl; cout << *b.upper_bound(6) << " " << *b.lower_bound(6) << endl; return 0; } /* 1 1 2 3 3 3 4 5 6 7 7 7 10 2 2 2 4 4 6 6 8 8 10 12 14 16 18 20 13 11 11 11 9 7 5 3 1 3 8 6 */ //基本用法与set一致,可以有多个重复元素