#include <iostream>
#include <list>
#include <functional>
#include <algorithm>
using namespace std;
int main()
{
list<int> listObject;
list<int>::iterator p, endp;
int i;
for(i =1; i < 20; i++)
listObject.push_back(i);
cout << "Original sequence:\n";
p = listObject.begin();
while(p != listObject.end()) {
cout << *p << " ";
p++;
}
cout << endl;
endp = remove_if(listObject.begin(), listObject.end(), bind2nd(greater<int>(), 8));
cout << "Resulting sequence:\n";
p = listObject.begin();
while(p != endp) {
cout << *p << " ";
p++;
}
return 0;
}
|