#include <stdio.h>
#include <stdlib.h>
void alocaMatriz(int **matriz, int lin, int col){
matriz = (int **)malloc(lin * sizeof(int **));
for (int i = 0; i < col; i++) matriz[i] = (int *)malloc(col * sizeof(int));
}
void leMatriz(int **matriz, int lin, int col){
printf("\nDigite os valores: ");
for (int i = 0; i < lin; i++) for (int j = 0; j < col; j++) scanf("%d", &matriz[i][j]);
}
int main(int argc, char** argv) {
int lin, col;
int **matriz;
printf("Digite as dimensoes da matriz: ");
scanf("%d %d", &lin, &col);
alocaMatriz(matriz, lin, col);
leMatriz(matriz, lin, col);
// mostraMatriz(matriz, lin, col);
}
//https://pt.stackoverflow.com/q/235435/101
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KIAp2b2lkIGFsb2NhTWF0cml6KGludCAqKm1hdHJpeiwgaW50IGxpbiwgaW50IGNvbCl7CiAgICBtYXRyaXogPSAoaW50ICoqKW1hbGxvYyhsaW4gKiBzaXplb2YoaW50ICoqKSk7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IGNvbDsgaSsrKSBtYXRyaXpbaV0gPSAoaW50ICopbWFsbG9jKGNvbCAqIHNpemVvZihpbnQpKTsKfQogCnZvaWQgbGVNYXRyaXooaW50ICoqbWF0cml6LCBpbnQgbGluLCBpbnQgY29sKXsKICAgIHByaW50ZigiXG5EaWdpdGUgb3MgdmFsb3JlczogIik7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IGxpbjsgaSsrKSBmb3IgKGludCBqID0gMDsgaiA8IGNvbDsgaisrKSBzY2FuZigiJWQiLCAmbWF0cml6W2ldW2pdKTsKfQogCmludCBtYWluKGludCBhcmdjLCBjaGFyKiogYXJndikgewogICAgaW50IGxpbiwgY29sOwogICAgaW50ICoqbWF0cml6OwogICAgcHJpbnRmKCJEaWdpdGUgYXMgZGltZW5zb2VzIGRhIG1hdHJpejogIik7CiAgICBzY2FuZigiJWQgJWQiLCAmbGluLCAmY29sKTsKICAgIGFsb2NhTWF0cml6KG1hdHJpeiwgbGluLCBjb2wpOwogICAgbGVNYXRyaXoobWF0cml6LCBsaW4sIGNvbCk7Ci8vICAgIG1vc3RyYU1hdHJpeihtYXRyaXosIGxpbiwgY29sKTsKfQoKLy9odHRwczovL3B0LnN0YWNrb3ZlcmZsb3cuY29tL3EvMjM1NDM1LzEwMQ==