Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // sort algorithm example
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main ()
- {
- int myints[] = {32,71,12,45,26,80,53,33};
- vector<int> myvector (myints, myints+8);
- // теперь в контейнере: 32 71 12 45 26 80 53 33
- vector<int>::iterator it;
- // сортируем первые 4 элемента
- sort (myvector.begin(), myvector.begin()+4);
- // теперь в контейнере: (12 32 45 71)26 80 53 33
- // печатаем содежимое
- cout << "myvector contains:";
- for (it=myvector.begin(); it!=myvector.end(); ++it)
- cout << " " << *it;
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement