Q:Write a program which read the following (3x3 dimensional) array and then display it.
#include <iostream>
#include <array>
int main() {
using Matrix = std::array<std::array<int, 3>, 3>;
Matrix m;
// read
for (size_t row = 0; row < 3; row++) {
for (size_t col = 0; col < 3; col++) {
std::cin >> m[row][col];
}
}
// display
for (auto const& r: m) {
for (auto c: r) {
std::cout << c << ' ';
}
std::cout << '\n';
}
return 0;
}
Comments