fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. vector<vector<int>> imat(3, vector<int>(10));
  9.  
  10. for_each(imat.begin(), imat.end(), [&](auto& i) { static auto row = 0; auto column = 0; transform(i.begin(), i.end(), i.begin(), [&](const auto& /*j*/) { return row * column++; }); ++row; });
  11.  
  12. for (auto &i : imat) {
  13. for (auto &j : i) {
  14. std::cout << j << '\t';
  15. }
  16. std::cout << std::endl;
  17. }
  18. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
0	0	0	0	0	0	0	0	0	0	
0	0	0	0	0	0	0	0	0	0	
0	0	0	0	0	0	0	0	0	0