Skip to content

Instantly share code, notes, and snippets.

@Pharaoh00
Created September 14, 2019 22:35
Show Gist options
  • Save Pharaoh00/cae91090b5d1d8e23f4f89b617c6d80a to your computer and use it in GitHub Desktop.
Save Pharaoh00/cae91090b5d1d8e23f4f89b617c6d80a to your computer and use it in GitHub Desktop.
int subRotinaEx30(int* vetor, int qtd, bool ordem){
// Ordem é a maneira que será imprimida.
// true = vetor[0], vetor[1], ..., vetor[n-1]
// false = vetor[n-1], ..., vetor[1], vetor[0]
int sum = 0;
if(qtd < 0){
return 0;
}
if(ordem == true){
subRotinaEx30(vetor, qtd - 1, ordem);
printf("%d ", vetor[qtd]);
sum += vetor[qtd]; // soma normal
}
else if(ordem == false){
printf("%d ", vetor[qtd]);
subRotinaEx30(vetor, qtd - 1, ordem);
sum += vetor[qtd];
}
return sum; // retorna o valor
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment