fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <array>
  4.  
  5. int main()
  6. {
  7.  
  8. //matrix com vector
  9. std::vector<std::vector<int>> matriz = { {7, 5}, {16, 8}};
  10.  
  11. for(std::vector<int> vetor : matriz) {
  12. for (int numero : vetor){
  13. std::cout << numero << ' ';
  14. }
  15. std::cout<<"\n";
  16. }
  17.  
  18. std::array<std::array<int, 3> , 2> matriz2 = {{ {{2 , 5, 3}} , {{1, 4, 8}} }};
  19.  
  20. for (auto& linha : matriz2){
  21. for (auto& num : linha){
  22. std::cout << num << ' ';
  23. }
  24.  
  25. std::cout<<"\n";
  26. }
  27. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
7 5 
16 8 
2 5 3 
1 4 8