#include #include using namespace std; bool cmp(int a, int b){ return a < b; } int main(){ auto cmpl = [](int a, int b){ return a > b; }; multimap a(cmp); multimap b(cmpl); a.insert({{1,"111"},{2,"222"},{1,"11"},{1,"1"},{2,"22"},{3,"333"}});//emplace只能用make_pair,不能直接这么写 //pair,Key是const修饰的 for(pair x : a){ cout << x.first << ", " << x.second << " "; } cout << endl; cout << a.find(1)->second << " " << a.count(1) << endl; a.erase(a.find(1)); cout << a.find(1)->second << " " << a.count(1) << endl; return 0; } /* 1, 111 1, 11 1, 1 2, 222 2, 22 3, 333 111 3 11 2 */