fork(2) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. const vector<string> a = {"good"s, "bad"s};
  10. const vector<string> b = {"apple"s, "mango"s};
  11. vector<string> output(a.size() * b.size());
  12.  
  13. for_each(begin(output), end(output), [&, it = 0U](auto& i) mutable {
  14. i = a[it / b.size()] + ' ' + b[it % b.size()];
  15. ++it;
  16. });
  17.  
  18. for(const auto& i : output) {
  19. cout << i << endl;
  20. }
  21. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
good apple
good mango
bad apple
bad mango