Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <limits.h> //INT_MAX
- int menorValor(int vet[], int tam, signed int temp);
- int main(void)
- {
- int vetor [] = {100,7,10,1000,-2,9,38,400,500,1,-500};
- printf("menor valor: %d",menorValor(vetor,10,INT_MAX) );
- return 0;
- }
- int menorValor(int vet[], int tam, signed int temp)
- {
- if(temp > vet[tam] ) // verificar se temp é maior do que elemento do vetor se for atualiza
- {
- temp=vet[tam];
- }
- if(tam==0) //critério de parada da recursividade
- {
- return temp;
- }
- return menorValor(vet, tam -1,temp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement