fun3.cpp
281 Bytes
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main ()
{
vector<int> numbers = {1,2,3,4};
int sum = 0;
for_each(numbers.begin(), numbers.end(), [&sum](int x) { sum += x;});
cout << sum << endl;
};