adjdiff2.cpp
adjdiff2.cpp
#include ‹stl.h›
#include ‹iostream.h›
int mult(int a_, int b_) {
return a_ * b_;
}
int main() {
vector‹int› v(10);
for (int i = 0; i ‹ v.size(); i++) v[i] = i + 1;
vector‹int› rslt(v.size());
adjacent_difference(v.begin(), v.end(), rslt.begin(), mult);
ostream_iterator‹int› iter(cout, " ");
copy(v.begin(), v.end(), iter);
cout ‹‹ endl;
copy(rslt.begin(), rslt.end(), iter);
cout ‹‹ endl;
return 0;
}