fork download
  1. #include<iostream>
  2. using std::cout; using std::cin; using std::endl;
  3. #include<vector>
  4. using std::vector;
  5.  
  6. long fn1(vector<long>& v, size_t indx){
  7. long result=0;
  8. long temp = v[indx];
  9. for (auto &e : v){ // Line 1
  10. e += temp;
  11. result += e;
  12. }
  13. return result;
  14. }
  15.  
  16. int main () {
  17. vector<vector<long>> v2d{ {0,1,2}, {3,4,5}, {6,7,8}, {9,10,11} };
  18. vector<long> v_result;
  19. long indx=0;
  20.  
  21. cout << fn1(v2d[0], 1) << endl; // Line 2
  22.  
  23. for (auto e : v2d[0]) // Line 3
  24. cout << e << " "; // Line 4
  25. cout << endl;
  26.  
  27. for (auto e : v2d) // Line 5
  28. v_result.push_back( fn1(e,indx++) );
  29.  
  30. cout << indx << endl; // Line 6
  31. cout << v_result.size() << endl; // Line 7
  32. cout << v_result[1] << endl; // Line 8
  33. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
6
1 2 3 
4
4
24