Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- //struct Lang
- //{
- // string name;
- // int age;
- //};
- //void PrintRange(vector<string>::iterator range_begin, vector<string>::iterator range_end)
- //{
- // for (auto it = range_begin; it != range_end; ++it)
- // {
- // cout << *it << " ";
- // }
- //}
- //using LangIt = vector<string>::iterator;
- //void PrintRange(LangIt range_begin, LangIt range_end)
- //{
- // for (auto it = range_begin; it != range_end; ++it)
- // {
- // cout << *it << " ";
- // }
- //}
- template<typename It>
- void PrintRange(It range_begin, It range_end)
- {
- for (auto it = range_begin; it != range_end; ++it)
- {
- cout << *it << " ";
- }
- }
- int main()
- {
- vector<string> langs = { "Python", "C++", "C", "Java", "C#" };
- PrintRange(begin(langs), end(langs));
- PrintRange(begin(langs[0]), end(langs[0]));
- //#######################################################################################################
- /*vector<Lang> langs = { {"Python", 26}, {"C++", 34}, {"C", 45}, {"Java", 22}, {"C#", 17} };
- auto result = find_if(begin(langs), end(langs), [](const Lang& lang)
- {return lang.name[0] == 'C'; });*/
- /*string lang = langs[1].name;
- auto it = begin(lang);
- cout << *it << endl;
- ++it;
- cout << *it << endl;*/
- // cout << end(langs)->name; НЕЛЬЗЯ!
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement