partsum2.cpp

We use cookies. Read the Privacy and Cookie Policy

partsum2.cpp

#include ‹stl.h›

#include ‹iostream.h›

int main() {

 vector‹int› v1(5);

 iota(v1.begin(), v1.end(), 1);

 vector‹int› v2(v1.size());

 partial_sum(v1.begin(), v1.end(), v2.begin(), times‹int›());

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

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

 cout ‹‹ endl;

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

 cout ‹‹ endl;

 return 0;

}