#include <stdio.h>
#include <stdlib.h>
#define LINHA 3
#define COLUNA 4
void matriz_ponteiro(int **mtr, size_t linhas, size_t colunas) {
for (int lin = 0; lin < linhas; lin++) {
for (int col = 0; col < colunas; col++) {
printf("\t%d", mtr
[lin
][col
]); }
}
}
int main () {
int **mtr
= malloc(LINHA
* sizeof(*mtr
)); int cont = 0;
for (int lin = 0; lin < LINHA; lin++) {
mtr
[lin
] = malloc(COLUNA
* sizeof(*mtr
[lin
])); for (int col = 0; col < COLUNA; col++) {
mtr[lin][col] = cont++;
}
}
matriz_ponteiro(mtr, LINHA, COLUNA);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2RlZmluZSBMSU5IQSAzCiNkZWZpbmUgQ09MVU5BIDQKCnZvaWQgbWF0cml6X3BvbnRlaXJvKGludCAqKm10ciwgc2l6ZV90IGxpbmhhcywgc2l6ZV90IGNvbHVuYXMpIHsKICAgICBmb3IgKGludCBsaW4gPSAwOyBsaW4gPCBsaW5oYXM7IGxpbisrKSB7CiAgICAgICAgZm9yIChpbnQgY29sID0gMDsgY29sIDwgY29sdW5hczsgY29sKyspIHsKICAgICAgICAgICAgIHByaW50ZigiXHQlZCIsIG10cltsaW5dW2NvbF0pOwogICAgICAgIH0gICAKICAgICAgICBwcmludGYoIlxuIik7CiAgICB9Cn0KCmludCBtYWluICgpIHsKICAgIGludCAqKm10ciA9IG1hbGxvYyhMSU5IQSAqIHNpemVvZigqbXRyKSk7CiAgICBpbnQgY29udCA9IDA7CiAgICBmb3IgKGludCBsaW4gPSAwOyBsaW4gPCBMSU5IQTsgbGluKyspIHsKICAgIAltdHJbbGluXSA9IG1hbGxvYyhDT0xVTkEgKiBzaXplb2YoKm10cltsaW5dKSk7CiAgICAgICAgZm9yIChpbnQgY29sID0gMDsgY29sIDwgQ09MVU5BOyBjb2wrKykgewogICAgICAgICAgICAgbXRyW2xpbl1bY29sXSA9IGNvbnQrKzsKICAgICAgICB9CiAgICB9CiAgICBtYXRyaXpfcG9udGVpcm8obXRyLCBMSU5IQSwgQ09MVU5BKTsKfQ==