Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Заготовки кода здесь нет — вы легко справитесь без неё. А вот решение не забудьте сохранить — оно
- вам понадобится в следующем задании.
- */
- #include <algorithm>
- #include <iostream>
- #include <set>
- #include <vector>
- using namespace std;
- /*void PrintRange(It range_begin, It range_end){
- bool first = true;
- auto i = range_begin;
- while(i!=range_end){
- if(first){
- cout<<*i;
- first=false;
- }else{
- cout<<" "<<*i;
- }
- ++i;
- }
- if(!first){
- cout<<endl;
- }
- }*/
- /*template <typename It>
- void PrintRange(It range_begin, It range_end) {
- for (auto it = range_begin; it != range_end; ++it) {
- cout << *it << " "s;
- }
- cout << endl;
- }*/
- template <typename Container, typename Element>
- void FindAndPrint(Container container, Element el) {
- auto find_el = find(begin(container), end(container), el);
- for (auto it = begin(container); it != find_el; ++it) {
- cout << *it << " "s;
- }
- cout << endl;
- for (auto it = find_el; it != end(container); ++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 << "End of tests"s << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment