Well, how can I resolve this exercise?
1- In the first line the user has to enter the size of the vector 2- In the second line, the user fills with integers 3 - make a recursive function that receives by reference the variables of greater and smaller values. The vector must be dynamically allocated.
I'm picking up a lot on this dynamic allocation. I made a sketch down here and so much more lost than blind in shooting -.-
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;
}