Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <map>
- using namespace std;
- 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(rbegin(langs), rend(langs));
- //cout << *rbegin(langs) << endl;
- //cout << *rend(langs) << endl; // нельзя
- /*auto it = rbegin(langs);
- cout << *it << " ";
- ++it;
- cout << *it << " ";*/
- auto it = find_if(rbegin(langs), rend(langs), [](const string& lang)
- {return lang[0] == 'C'; });
- нашел последний элемент!
- sort(rbegin(langs), rend(langs)); сортировка по убыванию
- cout << *it << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement