fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. int main()
  5. {
  6. std::cout << "Enter size of the array.\n> ";
  7.  
  8. std::size_t dim;
  9. std::cin >> dim;
  10.  
  11. std::vector<std::vector<double>> matrix(dim, std::vector<double>(dim));
  12.  
  13. std::cout << "Enter the elements of the array.\n> ";
  14. for (std::size_t row = 0; row < dim; ++row)
  15. for (std::size_t col = 0; col < dim; ++col)
  16. std::cin >> matrix[row][col];
  17.  
  18. std::cout << "The elements we're concerned with:\n";
  19.  
  20. for (std::size_t row = 0; row < dim; ++row) {
  21. for (std::size_t col = 0; col < row; ++col)
  22. std::cout << matrix[row][col] << ' ';
  23. std::cout << '\n';
  24. }
  25. }
Success #stdin #stdout 0s 3476KB
stdin
4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
stdout
Enter size of the array.
> Enter the elements of the array.
> The elements we're concerned with:

5 
9 10 
13 14 15