#include <iostream>
using namespace std;

const int n = 10;

// Arguably the most elegant solution: pointers to the columns of the
// matrix can be put into a separate array of pointers.  We no longer
// care about the dimension of the columns, and indeed there is no
// assumption that the columns occupy contiguous space.
//
// Note that in fact we can create the matrix as not necessarily
// contigous columns in the first place, depending on the application.

// We receive the matrix as an array of columnss (i.e., almost as a
// bidimensional array, but columnss do not necessarily ocupy
// contiguous memory space).
void display(int* m[], int size) {
    for (int i = 0; i < size; i++) {
        cout << "\n";
        for (int j = 0; j < size; j++)
            cout << m[i][j] << "\t";
    }
    cout << "\n";
}

int main () {
    int mm[n][n];  // real matrix

    int* passm[n]; // array of columns, to be passed to functions
    // Fill in the array of columns:
    for (int i = 0; i < n; i++)
        passm[i] = mm[i];
    // note that we set up pointers so the array of columns can be
    // created before the matrix if filled.

    // From now on mm and passm can be used intercheangeably.

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            mm[i][j] = i+j;

    display(passm,n);
}

