#include <stdio.h>
#include <stdlib.h>
int diagSecundaria(int lin, int col, float matriz[lin][col]) {
int i, j;
if (lin != col) {
return 0;
}
printf("Mostrando pelo primeiro método: \n"); for (i = 0; i < lin; i++) {
for (j = 0; j < col; j++) {
if (i + j == lin - 1) {
printf("%i %i: %.2f \n", i
, j
, matriz
[i
][j
]); }
}
}
printf("Mostrando pelo segundo método: \n"); for (i = 0; i < lin; i++) {
printf(":: %i %i: %.2f \n", i
, col
-1-i
, matriz
[i
][col
-1-i
]); }
return 1;
}
int main(void) {
int k, l, i, j, min, max,intervalo;
printf("Informe o tamanho da matriz: \n"); float mat[k][l];
//preenche a matriz
for (i = 0; i < k; i++) {
for (j = 0; j < l; j++) {
}
}
//mostra a matriz
for (i = 0; i < k; i++) {
for (j = 0; j < l; j++) {
}
}
if (diagSecundaria(k, l, mat) == 0) {
printf("Nao pode ser mostrada"); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBkaWFnU2VjdW5kYXJpYShpbnQgbGluLCBpbnQgY29sLCBmbG9hdCBtYXRyaXpbbGluXVtjb2xdKSB7CglpbnQgaSwgajsKCQoJaWYgKGxpbiAhPSBjb2wpIHsKCQlyZXR1cm4gMDsKCX0KCQoJcHJpbnRmKCJNb3N0cmFuZG8gcGVsbyBwcmltZWlybyBtw6l0b2RvOiBcbiIpOwoJZm9yIChpID0gMDsgaSA8IGxpbjsgaSsrKSB7CgkJZm9yIChqID0gMDsgaiA8IGNvbDsgaisrKSB7CgkJCWlmIChpICsgaiA9PSBsaW4gLSAxKSB7CgkJCQlwcmludGYoIiVpICVpOiAlLjJmIFxuIiwgaSwgaiwgbWF0cml6W2ldW2pdKTsKCQkJfQoJCX0KCX0KCQoJcHJpbnRmKCJNb3N0cmFuZG8gcGVsbyBzZWd1bmRvIG3DqXRvZG86IFxuIik7Cglmb3IgKGkgPSAwOyBpIDwgbGluOyBpKyspIHsKCQlwcmludGYoIjo6ICV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