#include
#include
#include
using namespace std;
double reciprocal(double val);
template void show(const char *msg, vector vect);
int main(){
int i;
vector v;
for(i=1; i < 10; ++i)
v.push_back((double)i);
show("Initial contents of v:", v);
cout << endl;
vector v2(10);
transform(v.begin(), v.end(), v2.begin(), reciprocal);
show("v2:", v2);
return 0;
}
template void show(const char *msg, vector vect) {
cout << msg << endl;
for(unsigned i=0; i < vect.size(); ++i)
cout << vect[i] << endl;
}
// Return the reciprocal
double reciprocal(double val) {
if(val == 0.0)
return 0.0;
return 1.0 / val;
}