accum1.cpp

We use cookies. Read the Privacy and Cookie Policy

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;

}