Advertisement
chevengur

CПРИНТ № 5 | Итераторы | Урок 3: Концепция полуинтервалов 1/2

Dec 25th, 2023
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <set>
  6.  
  7. using namespace std;
  8.  
  9. template <typename it>
  10. void PrintRange(it begin, it end){
  11.     for(auto iterator = begin; begin!=end; ++iterator, ++begin){
  12.         cout << *iterator << " ";
  13.     }
  14.     cout << endl;
  15. }
  16.  
  17.  
  18. int main() {
  19.     cout << "Test1"s << endl;
  20.     set<int> test1 = {1, 1, 1, 2, 3, 4, 5, 5};
  21.     PrintRange(test1.begin(), test1.end());
  22.     cout << "Test2"s << endl;
  23.     vector<int> test2 = {}; // пустой контейнер
  24.     PrintRange(test2.begin(), test2.end());
  25.     cout << "End of tests"s << endl;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement