#include #include #include using namespace std; void f(const int *p, size_t nrows, size_t ncols); int main() { int a[2][3] = { {1, 2, 3}, {4, 5, 6} }; int b[3][5] = { {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, }; f(reinterpret_cast(a), 2, 3); f(reinterpret_cast(b), 3, 5); return EXIT_SUCCESS; } void f(const int *p, size_t nrows, size_t ncols) { for (size_t i = 0; i < nrows; ++i) { for (size_t j = 0; j < ncols; ++j) { cout << setw(2) << p[i * ncols + j] << " "; } cout << "\n"; } cout << "\n"; }