fork download
  1. #include <algorithm>
  2. #include <deque>
  3. #include <iostream>
  4. #include <numeric>
  5. #include <set>
  6. #include <vector>
  7.  
  8. int main()
  9. {
  10. std::vector<int> v{ 1, 2, 3 };
  11. std::set<int> s{ 4, 5, 6 };
  12. std::deque<int> d(10);
  13.  
  14. std::iota(d.begin(), d.end(), 0);
  15.  
  16. const auto it{
  17. std::transform(v.cbegin(), v.cend(), s.cbegin(), d.begin(),
  18. [](const int x, const int y)
  19. {
  20. return x * y;
  21. })};
  22.  
  23. for (const int i : d)
  24. {
  25. std::cout << i << ' ';
  26. }
  27. std::cout << std::endl;
  28.  
  29. std::for_each(it, d.end(),
  30. [](const int i)
  31. {
  32. std::cout << i << ' ';
  33. });
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
4 10 18 3 4 5 6 7 8 9 
3 4 5 6 7 8 9