16.允许重复的multimap

 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 }

 

posted @ 2018-03-23 10:20  喵小喵~  阅读(121)  评论(0编辑  收藏  举报