Created
October 30, 2019 00:40
-
-
Save joaoBeno/37df0f72eddd7074af0174cccdb86bf0 to your computer and use it in GitHub Desktop.
Exercicio minimo maximo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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