Advertisement
Jonas_3k

/*- Busca Linear recursiva -*/

May 9th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. // Este código foi feito para o teste prático de algoritmos 2
  2. // Código para fins didáticos.
  3.  
  4. #include<stdio.h>
  5. #define vMAX 10
  6. int procure(int por,int *vetor,int tamanho)
  7. {
  8.     if(por==vetor[tamanho]) return tamanho;
  9.     else if (tamanho<=vMAX) procure(por,vetor,tamanho+1);
  10.     return -1;
  11.    
  12. }
  13. main()
  14. {
  15.     int numero,valor=0,indice,vetor[5];
  16.     for(indice=0;indice <5;indice++)
  17.     {
  18.         scanf("%d",&vetor[indice]);
  19.     }
  20.    
  21.     scanf("%d",&numero);
  22.     valor = procure(numero,vetor,0);
  23.     printf("valor retornado %d ",valor);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement