fork download
  1. #include <iostream>
  2.  
  3. #include <map>
  4.  
  5. #include <vector>
  6.  
  7. #include <sstream>
  8.  
  9. #include <string>
  10.  
  11. using namespace std;
  12.  
  13. int
  14. main ()
  15. {
  16.  
  17. int mynumbers[] = { 3, 9, 3, 2, 1, 4, 5 };
  18.  
  19. vector < int >v (mynumbers, mynumbers + 7);
  20.  
  21. map < int, string > m;;
  22.  
  23. for (vector < int >::iterator i = v.begin (); i != v.end (); i++)
  24. {
  25.  
  26. stringstream s;
  27.  
  28. s << *i;
  29.  
  30. m.insert (pair < int, string > (*i, s.str ()));
  31.  
  32. }
  33.  
  34. pair < map < int, string >::iterator, map < int, string >::iterator > range;
  35.  
  36. range = m.equal_range (3);
  37.  
  38. map < int, string >::iterator i = range.first; //LINE I
  39.  
  40. for (; i != range.second; i++)
  41.  
  42. {
  43.  
  44. cout << i->second << ", " << i->first << ", ";
  45.  
  46. }
  47.  
  48. return 0;
  49.  
  50. }
  51.  
Success #stdin #stdout 0.01s 5268KB
stdin
Standard input is empty
stdout
3, 3,