Advertisement
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>
- void PrintRange(it begin, it end){
- for(auto iterator = begin; begin!= end; ++iterator, ++begin){
- cout << *iterator << " ";
- }
- cout << endl;
- }
- template <typename con, typename elem>
- void FindAndPrint(con start_, elem num){
- auto begin_con = begin(start_);
- auto end_con = end(start_);
- auto stop_con = find(begin_con, end_con, num);
- PrintRange(begin_con, stop_con);
- PrintRange(stop_con, end_con);
- }
- 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 << "End of tests"s << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement