Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- signed main()
- {
- vector<int> v = {5 , 6 , 7 , 8};
- cout << *v.begin() << endl; // 5
- cout << *v.end() << endl; //random number
- cout << *(--v.end()) << endl; //8
- cout << *(v.end()--) << endl; // random number
- cout << *(v.begin()++) << endl; // 5
- cout << *(++v.begin()) << endl; // 6
- cout << *(v.begin() + 2) << endl; // number in 2-nd index
- sort(v.begin() , v.end());
- cout << *(lower_bound(v.begin() , v.end() , 7)) << endl; // 7
- cout << *(upper_bound(v.begin() , v.end() , 7)) << endl; // 8
- cout << *(upper_bound(v.begin() , v.end() , 8)) << endl; // random number
- auto it = v.begin();
- cout << *it << endl; // 5
- vector<int>::iterator pt = v.end();
- pt--;
- cout << *pt << endl; // 8
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement