#include <vector>#include <iostream>#include <functional>#include <algorithm>using namespace std;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;}
#include <numeric>
#include <iostream>#include <numeric>using namespace std;int main (){ int numbers[10]; iota (numbers, numbers + 10, 42); for (int i = 0; i < 10; i++) cout << numbers[i] << ' '; cout << endl; return 0;}