#include <stdio.h>
int main(void) {
int mat[3][3] = {1,3,5,
3,7,2,
0,5,1}, i, j, maior, smaior;
maior = mat[0][0];
smaior = maior;
for (i = 0; i < 3; i++) {
for (j=0; j < 3; j++) {
if (mat[i][j] > maior) {
smaior = maior;
maior = mat[i][j];
}
}
}
for (i = 0; i < 3; i++) {
for (j=0; j < 3; j++) {
if (mat[i][j] == smaior) {
printf("Posicao: %i %i\n", i
, j
); i = 5;
j = 5;
}
}
}
printf("Maior: %i \n", maior
); printf("Segundo Maior: %i", smaior
); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbih2b2lkKSB7CglpbnQgbWF0WzNdWzNdID0gezEsMyw1LAoJCSAgICAgMyw3LDIsCgkJICAgICAwLDUsMX0sIGksIGosIG1haW9yLCBzbWFpb3I7CgkKCW1haW9yID0gbWF0WzBdWzBdOwoJc21haW9yID0gbWFpb3I7Cglmb3IgKGkgPSAwOyBpIDwgMzsgaSsrKSB7CgkJZm9yIChqPTA7IGogPCAzOyBqKyspIHsKCQkJaWYgKG1hdFtpXVtqXSA+IG1haW9yKSB7CgkJCQlzbWFpb3IgPSBtYWlvcjsKCQkJCW1haW9yID0gbWF0W2ldW2pdOwoJCQl9CQoJCX0KCX0KCQoJZm9yIChpID0gMDsgaSA8IDM7IGkrKykgewoJCWZvciAoaj0wOyBqIDwgMzsgaisrKSB7CgkJCWlmIChtYXRbaV1bal0gPT0gc21haW9yKSB7CgkJCQlwcmludGYoIlBvc2ljYW86ICVpICVpXG4iLCBpLCBqKTsKCQkJCWkgPSA1OwoJCQkJaiA9IDU7CgkJCX0JCgkJfQoJfQoKCXByaW50ZigiTWFpb3I6ICVpIFxuIiwgbWFpb3IpOwoJcHJpbnRmKCJTZWd1bmRvIE1haW9yOiAlaSIsIHNtYWlvcik7CglyZXR1cm4gMDsKfQo=