Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <set>
- using namespace std;
- template <typename It, typename E>
- void FindAndPrint(set<It> container, E element) {
- auto item = find_if(container.begin(), container.end(),
- [element](It ele) {
- return ele == element;
- });
- for (auto it = container.begin(); it != item; ++it) {
- cout << *it << " "s;
- }
- cout << endl;
- for (auto it = item; it != container.end(); ++it) {
- cout << *it << " "s;
- }
- cout << endl;
- }
- int main() {
- set<int> test = { 1, 1, 1, 2, 3, 4, 5, 5 };
- cout << "Test1"s << endl;
- FindAndPrint(test, 3);
- cout << "Test2"s << endl;
- FindAndPrint(test, 0); // элемента 0 нет в контейнере
- cout << "Test3"s << endl;
- FindAndPrint(test, -4);
- cout << "End of tests"s << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment