Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void calculo(double array_notas[5], int index, double max, double min, double soma) {
  4.     if (index == 5) {
  5.         printf("%.1lf", soma);
  6.         return;
  7.     }
  8.  
  9.     if (array_notas[index] != max && array_notas[index] != min) {
  10.         soma += array_notas[index];
  11.     }
  12.  
  13.     calculo(array_notas, index + 1, max, min, soma);
  14. }
  15.  
  16. void ler_array(int amount, double array_notas[5], double max, double min, int index) {
  17.     if (amount == 0) {
  18.         double soma = 0;
  19.         calculo(array_notas, 0, max, min, soma);
  20.         return;
  21.     }
  22.     double nota;
  23.     scanf("%lf", &nota);
  24.    
  25.     if (nota > max) {
  26.         max = nota;
  27.     }
  28.     if (nota < min) {
  29.         min = nota;
  30.     }
  31.     array_notas[index] = nota;
  32.     ler_array(amount - 1, array_notas, max, min, index + 1);
  33. }
  34.  
  35. int main() {
  36.     int amount = 5;
  37.     double array_notas[5];
  38.    
  39.     ler_array(amount, array_notas, -99999, 99999, 0);
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement