Advertisement
Guest User

find_el

a guest
Mar 31st, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. #include <vector>
  4. #include <string>
  5. #include <map>
  6. #include <algorithm>
  7.  
  8. using namespace std;
  9.  
  10. template <typename T>
  11. vector<T> FindGreaterElements(const set<T>& elements, const T& border) {
  12.     vector<T> res = {};
  13.     auto found = find(begin(elements), end(elements), border);
  14.     if (found != end(elements)) {
  15.         ++found;
  16.         for (auto i = found; i != end(elements); ++i) {
  17.             res.push_back(*i);
  18.         }
  19.     }
  20.     return res;
  21. }
  22.  
  23. int main() {
  24.     //FindGreaterElements(set<int>{1, 5, 7, 8}, 5);
  25.     for (int x : FindGreaterElements(set<int>{1, 5, 7, 8}, 5)) {
  26.         cout << x << " ";
  27.     }
  28.     cout << endl;
  29.  
  30.     string to_find = "Python";
  31.     cout << FindGreaterElements(set<string>{"C", "C++"}, to_find).size() << endl;
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement