shushus

Спринт 5. Концепция полуинтервалов. Задание 1.

Dec 10th, 2022
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. /*
  2. Заготовки кода здесь нет — вы легко справитесь без неё. А вот решение не забудьте сохранить — оно
  3. вам понадобится в следующем задании.
  4. */
  5. #include <iostream>
  6. #include <set>
  7. #include <vector>
  8. using namespace std;
  9. template <typename It>
  10. void PrintRange(It range_begin, It range_end){
  11.     bool first = true;
  12.     auto i = range_begin;
  13.     while(i!=range_end){
  14.         if(first){
  15.             cout<<*i;
  16.             first=false;
  17.         }else{
  18.             cout<<" "<<*i;
  19.         }
  20.         ++i;
  21.     }
  22.     if(!first){
  23.         cout<<endl;
  24.     }
  25. }
  26. int main() {
  27.     cout << "Test1"s << endl;
  28.     set<int> test1 = {1, 1, 1, 2, 3, 4, 5, 5};
  29.     PrintRange(test1.begin(), test1.end());
  30.     cout << "Test2"s << endl;
  31.     vector<int> test2 = {}; // пустой контейнер
  32.     PrintRange(test2.begin(), test2.end());
  33.     cout << "End of tests"s << endl;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment