First page Back Continue Last page Graphics
#include <iostream>
- #include <iostream>
- #include <list>
- #include <algorithm>
- using namespace std;
- int main()
- { list<int> coll;
- // insert elements from 20 to 40
- for(int i=20; i<=40; ++i) coll.push_back(i);
- // find positions of values 25 and 35
- list<int>::iterator pos25, pos35;
- pos25 = find(coll.begin(), coll.end(), 25);
- pos35 = find(coll.begin(), coll.end(), 35);
- // print the maximum of the corresponding range (includes pos25, excludes pos35).
- cout<<”max: “<< *max_element(pos25,pos35) << endl;