#include <iostream>
#include <list>
#include <functional>
#include <algorithm>
using namespace std;
int main()
{
list<double> l;
int i;
for(i=1; i<10; i++) l.push_back((double)i);
list<double>::iterator p = l.begin();
while(p != l.end()) {
cout << *p << " ";
p++;
}
cout << endl;
p = transform(l.begin(), l.end(),l.begin(),negate<double>());
cout << "Negated contents of the list:\n";
p = l.begin();
while(p != l.end()) {
cout << *p << " ";
p++;
}
return 0;
}
|