adjdiff1.cpp

We use cookies. Read the Privacy and Cookie Policy

adjdiff1.cpp

#include ‹stl.h›

#include ‹iostream.h›

int main() {

 vector‹int› v(10);

 for (int i = 0; i ‹ v.size(); i++) v[i] = i * i;

 vector‹int› result(v.size());

 adjacent_difference(v.begin(), v.end(), result.begin());

 ostream_iterator‹int› iter(cout, " ");

 copy(v.begin(), v.end(), iter);

 cout ‹‹ endl;

 copy(result.begin(), result.end(), iter);

 cout ‹‹ endl;

 return 0;

}