#include <stdio.h>
#define TAM 20 //cria uma constante
int main() {
int vet[TAM], i, maior, posMaior, menor, posMenor;
//preenche o vetor
for (i = 0; i < TAM; i++) {
}
//encontra o maior valor
maior = vet[0];
posMaior = 0;
for (i = 1; i < TAM; i++) {
if (vet[i] > maior) {
maior = vet[i];
posMaior = i;
}
}
//encontra o menor valor
menor = vet[0];
posMenor = 0;
for (i = 1; i < TAM; i++) {
if (vet[i] < menor) {
menor = vet[i];
posMenor = i;
}
}
//mostra o vetor
for (i = 0; i < TAM; i++) {
}
printf("\nMaior valor: %i - posicao: %i", maior
, posMaior
+1); printf("\nMenor valor: %i - posicao: %i", menor
, posMenor
+1);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgojZGVmaW5lIFRBTSAyMCAvL2NyaWEgdW1hIGNvbnN0YW50ZQoKaW50IG1haW4oKSB7CiAgICBpbnQgdmV0W1RBTV0sIGksIG1haW9yLCBwb3NNYWlvciwgbWVub3IsIHBvc01lbm9yOwoKICAgIC8vcHJlZW5jaGUgbyB2ZXRvcgogICAgZm9yIChpID0gMDsgaSA8IFRBTTsgaSsrKSB7CiAgICAgICAgc2NhbmYoIiVpIiwgJnZldFtpXSk7CiAgICB9CgogICAgLy9lbmNvbnRyYSBvIG1haW9yIHZhbG9yCiAgICBtYWlvciAgICA9IHZldFswXTsKICAgIHBvc01haW9yID0gMDsKICAgIGZvciAoaSA9IDE7IGkgPCBUQU07IGkrKykgewogICAgICAgIGlmICh2ZXRbaV0gPiBtYWlvcikgewogICAgICAgICAgICBtYWlvciAgICA9IHZldFtpXTsKICAgICAgICAgICAgcG9zTWFpb3IgPSBpOwogICAgICAgIH0KICAgIH0KCiAgICAvL2VuY29udHJhIG8gbWVub3IgdmFsb3IKICAgIG1lbm9yICAgID0gdmV0WzBdOwogICAgcG9zTWVub3IgPSAwOwogICAgZm9yIChpID0gMTsgaSA8IFRBTTsgaSsrKSB7CiAgICAgICAgaWYgKHZldFtpXSA8IG1lbm9yKSB7CiAgICAgICAgICAgIG1lbm9yICAgID0gdmV0W2ldOwogICAgICAgICAgICBwb3NNZW5vciA9IGk7CiAgICAgICAgfQogICAgfQoKICAgIC8vbW9zdHJhIG8gdmV0b3IKICAgIHByaW50ZigiVmV0b3I6ICIpOwogICAgZm9yIChpID0gMDsgaSA8IFRBTTsgaSsrKSB7CiAgICAgICAgcHJpbnRmKCIlaSAiLCB2ZXRbaV0pOwogICAgfQoKICAgIHByaW50ZigiXG5NYWlvciB2YWxvcjogJWkgLSBwb3NpY2FvOiAlaSIsIG1haW9yLCBwb3NNYWlvcisxKTsKICAgIHByaW50ZigiXG5NZW5vciB2YWxvcjogJWkgLSBwb3NpY2FvOiAlaSIsIG1lbm9yLCBwb3NNZW5vcisxKTsKCiAgICByZXR1cm4gMDsKfQ==