Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <string>
- #include <vector>
- #include <numeric>
- #include <algorithm>
- #include <execution>
- #include <ctime>
- #include <functional>
- using namespace std;
- int main() {
- vector<int> v{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- int sum = accumulate(v.begin(), v.end(), 0);
- cout << sum << endl;
- map<string, int> peoples{{"First"s, 2}, {"Second"s, 8}, {"Ivan"s, 35}};
- int result = accumulate(peoples.begin(), peoples.end(), 0, [](int sum, pair<string, int> people) {
- return sum += people.second;
- });
- cout << result << endl;
- cout << "========================="s << endl;
- vector<int> elements(100'000'000u);
- iota(elements.begin(), elements.end(), 0);
- clock_t begin = clock();
- for_each(execution::par, elements.begin(), elements.end(), [](int& elem) {
- elem *= 10;
- });
- clock_t end = clock();
- cout << "time for_each "s << end - begin << " ms"s << endl;
- const double PI = 3.14;
- int value = 5;
- function<void(int&)> func = [&value](int& elem) {
- value = 10;
- //elem = 16;
- };
- func(value);
- cout << value << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment