#include <stdio.h>
#include <stdlib.h>
void matriz_ponteiro(int *matriz, int linhas, int colunas) {
int lin, col;
for (lin = 0; lin < linhas; lin++) {
for (col = 0; col < colunas; col++) {
printf("\t%d", matriz
[lin
* colunas
+ col
]); }
}
}
int main() {
int mtr[3][4];
int lin, col, cont;
cont = 0;
// armazenar o valor de cont em cada posição da matriz
for (lin = 0; lin < 3; lin++) {
for (col = 0; col < 4; col++) {
mtr[lin][col] = cont++;
}
}
matriz_ponteiro(mtr[0], 3, 4);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnZvaWQgbWF0cml6X3BvbnRlaXJvKGludCAqbWF0cml6LCBpbnQgbGluaGFzLCBpbnQgY29sdW5hcykgewogICAgaW50IGxpbiwgY29sOwogICAgZm9yIChsaW4gPSAwOyBsaW4gPCBsaW5oYXM7IGxpbisrKSB7CiAgICAgICAgaWYgKGxpbiAhPSAwKSBwcmludGYoIlxuIik7CiAgICAgICAgZm9yIChjb2wgPSAwOyBjb2wgPCBjb2x1bmFzOyBjb2wrKykgewogICAgICAgICAgICBwcmludGYoIlx0JWQiLCBtYXRyaXpbbGluICogY29sdW5hcyArIGNvbF0pOwogICAgICAgIH0KICAgIH0KfQoKaW50IG1haW4oKSB7CiAgICBpbnQgbXRyWzNdWzRdOwogICAgaW50IGxpbiwgY29sLCBjb250OwogICAgY29udCA9IDA7CiAgICAvLyBhcm1hemVuYXIgbyB2YWxvciBkZSBjb250IGVtIGNhZGEgcG9zacOnw6NvIGRhIG1hdHJpegogICAgZm9yIChsaW4gPSAwOyBsaW4gPCAzOyBsaW4rKykgewogICAgICAgIGZvciAoY29sID0gMDsgY29sIDwgNDsgY29sKyspIHsKICAgICAgICAgICAgbXRyW2xpbl1bY29sXSA9IGNvbnQrKzsKICAgICAgICB9CgogICAgfQogICAgbWF0cml6X3BvbnRlaXJvKG10clswXSwgMywgNCk7Cn0=