#include <iostream>
using namespace std;
#include <map>
#include <string>
typedef multimap<string, string> M;
int main()
{
M mss;
M::iterator ib ,ie;
mss.insert(make_pair("aa", "bb"));
mss.insert(make_pair("cc", "dd"));
mss.insert(make_pair("ee", "ff"));
mss.insert(make_pair("cc", "pp"));
mss.insert(make_pair("aa", "mm"));
mss.insert(make_pair("cc", "dd"));
mss.insert(make_pair("aa", "kk"));
ib = mss.begin();
ie = mss.end();
while(ib!=ie)
{
cout << ib->first << "的好友" << ib->second << endl;
++ib;
}
cout << "aa的好友数量:" << mss.count("aa") << endl;
cout << "cc的所有好友:" << endl;
ib = mss.lower_bound("cc");
ie = mss.upper_bound("cc");
while(ib!=ie)
{
cout << ib->second<< ' ';
++ib;
}
cout << endl;
return 0;
}
multimap
最新推荐文章于 2024-07-18 21:47:07 发布