1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <functional>
using namespace std;
int main()
{
vector<int> myVec = {1, 5, 3, 2, 9, 8, 7, 2, 4, 1, 5, 6, 3, 6};
//print contents of myVec to the screen
cout << "Unsorted" << endl;
copy(myVec.begin(), myVec.end(), ostream_iterator<int>(cout, " "));
//sort myVec
sort(myVec.begin(), myVec.end());
//print contents of myVec to the screen
cout << "\nSorted" << endl;
copy(myVec.begin(), myVec.end(), ostream_iterator<int>(cout, " "));
return 0;
}
|