accum1.cpp

accum1.cpp

#include ‹ospace/stl.h›

#include ‹iostream.h›

int main() {

 vector‹int› v(5);

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

 int sum = accumulate(v.begin(), v.end(), 0);

 cout ‹‹ "sum = " ‹‹ sum ‹‹ endl;

 return 0;

}