#include <iostream> #include <list> #include <algorithm> using namespace std; double reciprocal(double i) { return 1.0/i; } 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 << endl; p++; } p = transform(l.begin(), l.end(),l.begin(), reciprocal); p = l.begin(); while(p != l.end()) { cout << *p << endl; p++; } return 0; }