#include <map>
#include <string>
#include <iostream>
using namespace std;
int main()
{
multimap<string,string>mymap;
mymap.insert(multimap<string,string>::value_type("ho","123"));
mymap.insert(multimap<string,string>::value_type("hu","234"));
mymap.insert(multimap<string,string>::value_type("lian","345"));
mymap.insert(multimap<string,string>::value_type("ho","555"));
mymap.insert(multimap<string,string>::value_type("hu","444"));
mymap.insert(multimap<string,string>::value_type("ho","333"));
int num=mymap.count("ho");
switch(num)
{
case 0:
break;
case 1:
break;
default:
{
multimap<string,string>::iterator i;
pair< multimap<string,string>::iterator, multimap<string,string>::iterator>pos;
pos=mymap.equal_range("ho");
for(i=pos.first;i!=pos.second;i++)
{
cout<<i->second <<endl;
}
}
break;
}
return 0;
}
输出
123
555
333