#include #include #include #include #include // for INT_MIN using namespace std; int main() { vector vec = {1,4,5,8,9,2,6,4,32,7,19}; // print the vector auto printv = [](int i) { cout << i << " "; }; for_each(vec.begin(),vec.end(), printv); cout << endl; // find the maximum value in the vector int max = INT_MIN; for_each(vec.begin(),vec.end(), [&max](int i) { if (i > max) max = i; }); cout << "The maximum value is " << max << endl; // sort the vector sort(vec.begin(),vec.end(), [](const int& i, const int& j) { return i < j; }); for_each(vec.begin(),vec.end(), printv); cout << endl; // how many vector values are greater than 10 cout << "The are " << count_if(vec.begin(), vec.end(),[](int i) { return i > 10; }) << " values greater than 10" << endl; generate(vec.begin(),vec.end(),[] { return rand() % 100;}); for_each(vec.begin(),vec.end(), printv); cout << endl; }