1 #include <iostream> 2 #include <map> 3 #include <cstring> 4 using namespace std; 5 6 7 void main() 8 { 9 multimap<char *, int>mymap; 10 mymap.insert(pair<char *, int>("司令1", 10)); 11 mymap.insert(pair<char *, int>("司令1", 11)); 12 mymap.insert(pair<char *, int>("司令3", 12)); 13 mymap.insert(pair<char *, int>("司令4", 13)); 14 mymap.insert(pair<char *, int>("司令5", 14)); 15 16 17 18 for (auto i : mymap) 19 { 20 cout << i.first << " " << i.second << endl; 21 } 22 23 auto it = mymap.equal_range("司令1"); 24 for (auto ib = it.first, ie = it.second; ib != ie; ib++) 25 { 26 cout << (*ib).first << " " << (*ib).second << endl; 27 } 28 cin.get(); 29 }