SHARE
TWEET

Untitled

a guest Jun 17th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <iterator>
  5. #include <unordered_map>
  6. #include <map>
  7. #include <algorithm>
  8. #include <vector>
  9. #include <set>
  10.  
  11. using namespace std;
  12.  
  13.  
  14.  
  15. bool p1(int a)
  16. {
  17.     return a < 0;
  18. }
  19.  
  20.  
  21. bool p2(pair<int, string> n)
  22. {
  23.     return n.first > 0;
  24. }
  25.  
  26. int p3(pair <int, string> n)
  27. {
  28.     return n.first;
  29. }
  30. void p4(pair<int, string> n)    
  31. {
  32.     cout << endl << n.first << "  " << n.second<< endl;
  33.  }
  34.  
  35.  
  36. void p5(int  n)
  37. {
  38.     cout << endl << n << endl;
  39. }
  40.  
  41. bool p6(int n, int l)
  42. {
  43.     if (n < l)
  44.     {
  45.         return  0;
  46.     }
  47.     else
  48.     {
  49.         return 1;
  50.     }
  51. }
  52.  
  53.  
  54. int main()
  55. {
  56.     unordered_multimap <int, string> magazin;
  57.     cout << "Dobro pogalovat v moi velikolepni magazin" << endl;
  58.     magazin = { { -3, "banan" }, {1, "ogyrec"}, {-17, "ananas"} };
  59.  
  60.     for_each(magazin.begin(), magazin.end(), p4);
  61.  
  62.     cout << "___________________________________";    
  63.  
  64.     magazin.insert({ 3, "sok" });
  65.     magazin.insert({ 3, "mango" });
  66.     magazin.insert({ 3, "tomat" });
  67.  
  68.     for_each(magazin.begin(), magazin.end(), p4);
  69.  
  70.     magazin.erase(-3);
  71.  
  72.     cout << "___________________________________";
  73.     for_each(magazin.begin(), magazin.end(), p4);
  74.     map <int, string> magazin2(magazin.begin(), magazin.end());
  75.  
  76.     cout << "___________________________________";
  77.     for_each(magazin2.begin(), magazin2.end(), p4);
  78.  
  79.     int kol;   
  80.     kol=count_if(magazin2.begin(), magazin2.end(), p2);
  81.  
  82.     cout << "___________________________________";
  83.     cout << endl << "Kolichestvo=" << kol << endl;
  84.  
  85.    
  86.     vector <int> my;
  87.     my.resize(magazin2.size());
  88.  
  89.      transform(magazin2.begin(), magazin2.end(), my.begin(), p3);
  90.  
  91.      cout << "___________________________________" << endl;
  92.      for_each(my.begin(), my.end(), p5);
  93.      cout << "___________________________________" << endl;
  94.      
  95.      if ( find( my.begin(), my.end(), 1) != my.end())
  96.      {
  97.          cout << endl << "Found " << '\n';
  98.      }
  99.      else {
  100.          cout << endl << "Not found\n";
  101.      }
  102.  
  103.      replace_if(my.begin(), my.end(), p1, 0);
  104.  
  105.      cout << "___________________________________" << endl;
  106.      for_each(my.begin(), my.end(), p5);
  107.  
  108.    
  109.      sort(my.begin(), my.end(), p6);
  110.  
  111.      cout << "___________________________________" << endl;
  112.      for_each(my.begin(), my.end(), p5);
  113.  
  114.      set <int> mu(my.begin(), my.end());
  115.  
  116.      cout << "___________________________________" << endl;
  117.      for_each(mu.begin(), mu.end(), p5);
  118.  
  119.  
  120. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top