0
Guys, how can I solve this exercise?
1-on the first line the user has to type the vector size 2- in the second line, the user fills in integers 3- make a recursive function that receives by reference the variables of higher and lower values. The vector should be dynamically allocated.
I’m picking up a lot on this dynamic allocation. I did a sketch down here and I’m more lost than blind in a gunfight -.-
void procurar(int vetor[], int *tamanho, int *maior, int *menor){    
int i, j, aux; 
  for(i = 1; i < *tamanho; i++){ 
    j = i; 
    while((j != 0) && (*vetor[j] > *vetor[j - 1])) { 
      aux = *vetor[j]; 
      *vetor[j] = *vetor[j - 1]; 
      *vetor[j-1] = aux; 
      j--;     
    } 
  }
  *maior = *vetor[*tamanho];
  *menor = *vetor[0];
}
int main(){
    int tamanho, i, maior, menor;
    maior = 0;
    scanf("%d", &tamanho);
    int vetor[tamanho];
    for(i=0; i<tamanho; i++){
        scanf("%d", &vetor[i]);
    }
    procurar(&vetor, &tamanho, &maior, &menor);
    printf("%d %d", maior, menor);``
    return 0;
}
There will always be someone who disagrees, and who will give you the solution, but it bothers me if making a recursive algorithm when clearly an iterative works better. At bottom is teaching wrong. (in the sense of using the least suitable tool for the specific problem)
– Maniero