Skip to content

Instantly share code, notes, and snippets.

@joaoBeno
Created October 30, 2019 00:40
Show Gist options
  • Save joaoBeno/37df0f72eddd7074af0174cccdb86bf0 to your computer and use it in GitHub Desktop.
Save joaoBeno/37df0f72eddd7074af0174cccdb86bf0 to your computer and use it in GitHub Desktop.
Exercicio minimo maximo
#include <stdio.h>
void maximoMinimo(int *v, int N, int *maximo, int *minimo);
int main() {
int t = 4;
int vt[4] = {2,3,4,5};
int max, min;
maximoMinimo(&vt, t, &max, &min);
printf("Maximo: %i, minimo: %i", max, min);
return 0;
}
void maximoMinimo(int *v, int N, int *maximo, int *minimo){
int max, min, i;
for(i=0;i<N;i++) {
if (i == 0) {
max = 0;
min = 2000000;
}
max = (v[i] > max) ? v[i] : max;
min = (v[i] < min) ? v[i] : min;
}
*maximo = max;
*minimo = min;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment