fork(2) download
  1. #include <map>
  2. #include<iostream>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int main() {
  8. multimap<int,string> m;
  9. m.insert({1,"hello"});
  10. m.insert({1,"world"});
  11. m.insert({2,"goodbye"});
  12. m.insert({3,"spacecows"});
  13.  
  14. cout<<"Number of elements in key 1: "<<m.count(1)<<endl;
  15.  
  16. auto range = m.equal_range(1);
  17. for(auto iter = range.first; iter != range.second; iter++) cout<<iter->second<<" ";
  18. cout<<endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Number of elements in key 1: 2
hello world