Advertisement
Guest User

davidnak

a guest
May 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <string>
  6. #include <functional>
  7.  
  8. struct cmpByStringLength {
  9.     bool operator()(const std::string& a, const std::string& b) const {
  10.         return a < b;
  11.     }
  12. };
  13.  
  14.  
  15. bool less(std::string a, std::string b)
  16. {
  17.     return (a <= b); //ABC sorrend
  18. }
  19.  
  20.  
  21. int main(){
  22.  
  23.     //std::map<std::string, int, std::less<int>> map_neve;
  24.     //std::map<std::string, int> map_neve;
  25.     std::map<std::string,std::string> mymap;
  26.  
  27.     mymap["Csongor"] = std::string("Marcius");
  28.     mymap["Balazs"] = std::string("Februar");
  29.     mymap["Panni"] = std::string("December");
  30.     mymap["Orsi"] = std::string("Oktober");
  31.  
  32.      //std::cout << "A map merete: " << ;
  33.  
  34.     for(auto it = mymap.begin(); it != mymap.end(); it++)
  35.     {
  36.  
  37.         std::cout << it->first << "\t" << it->second << std::endl;
  38.     }
  39.  
  40.  
  41.  
  42.     std::map<int,std::string, value_comp> mymap2;
  43.  
  44.     //std::cout << less("Anna", "Horcsi");
  45.  
  46.     //mymap2.insert(std::string("Lilla"));
  47. //    mymap2[1] = std::string("Lilla");
  48. //    mymap2[2] = std::string("Lori");
  49. //    mymap2[3] = std::string("Viktor");
  50. //    mymap2[4] = std::string("Geri");
  51.  
  52. //    for(auto it = mymap2.begin(); it != mymap2.end(); it++)
  53. //    {
  54.  
  55. //        std::cout << it->first << " - " << it->second << std::endl;
  56. //    }
  57.  
  58. //    for (std::vector<std::pair<int,std::string>>::iterator it=rendezo.begin(); it!=rendezo.end();it++)
  59. //    {
  60. //        std::cout << it->first << " -> " << it->second << std::endl;
  61.  
  62. //    }
  63.  
  64.  
  65.  
  66.  
  67.         //konstruktorba compare
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement