avr39ripe

PV913AdvSTLExamples

Aug 18th, 2020
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <list>
  4. #include <algorithm>
  5.  
  6.  
  7.  
  8. int main()
  9. {
  10.     std::vector<int> arr{1,2,3,4,5,6,7,8,9,10};
  11.     std::list<char> symbols{'a','s','d','a','s','x','v'};
  12.  
  13.    
  14.  
  15.     /*auto it{ arr.begin() };
  16.  
  17.     while ((it = std::find(it, arr.end(), 1)) != arr.end())
  18.     {
  19.         std::cout << "res is: " << std::distance(arr.begin(), it) << " <=> " << *it << '\n';
  20.         ++it;
  21.     }*/
  22.     std::copy(arr.begin(), arr.end(), std::ostream_iterator<int>(std::cout, " ")); std::cout << '\n';
  23.     std::cout << '\n';
  24.  
  25.     std::stable_partition(arr.begin(), arr.end(), [](int el) { return el % 2; });
  26.  
  27.     std::copy(arr.begin(), arr.end(), std::ostream_iterator<int>(std::cout, " ")); std::cout << '\n';
  28.     std::cout << '\n';
  29.  
  30.     //auto res{ std::find(arr.begin(), arr.end(), 0)};
  31.     //auto res{ std::count_if(arr.begin(), arr.end(),[](int el) { return (el % 2 == 0) and (el > 5); }) };
  32.  
  33.  
  34.  
  35.     /*if (res != arr.end())
  36.     {
  37.         std::cout << "res is: " << std::distance(arr.begin(), res) << " <=> " << *res << '\n';
  38.     }
  39.     else
  40.     {
  41.         std::cout << "Not FOUND!!\n";
  42.     }*/
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment