fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main()
  5. {
  6. vector<vector<double>>out = {{1,2}, {3,4}, {5,6}};
  7.  
  8. std::cout << "out: \n";
  9. for(size_t i=0; i<out.size(); ++i)
  10. {
  11. for(size_t j=0; j<out[0].size(); ++j)
  12. std::cout << out[i][j] << ' ';
  13. std::cout << '\n';
  14. }
  15.  
  16. vector<vector<double>> outtrans(out[0].size(),
  17. vector<double>(out.size()));
  18. for (size_t i = 0; i < out.size(); ++i)
  19. for (size_t j = 0; j < out[0].size(); ++j)
  20. outtrans[j][i] = out[i][j];
  21.  
  22. std::cout << "outtrans: \n";
  23. for(size_t i=0; i<outtrans.size(); ++i)
  24. {
  25. for(size_t j=0; j<outtrans[0].size(); ++j)
  26. std::cout << outtrans[i][j] << ' ';
  27. std::cout << '\n';
  28. }
  29. }
  30.  
Success #stdin #stdout 0s 2964KB
stdin
Standard input is empty
stdout
out: 
1 2 
3 4 
5 6 
outtrans: 
1 3 5 
2 4 6