Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Use of the std::iter_swap.
- #include <stdio.h>
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main()
- {vector<int> v1;
- int i;
- for (i = 0; i < 200; ++i) {
- v1.push_back(i);
- }
- vector<int>::iterator i1, i2;
- i1 = v1.begin();
- i2 = v1.end() - 1;
- // Swap
- std::iter_swap(i1, i2);
- for (i = 0; i < 200; ++i) {
- cout << v1[i] << " ";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment