Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. double le_numero()
  5. {
  6.  
  7.     double num;
  8.  
  9.     scanf("%lf",&num);
  10.  
  11.     return num;
  12.  
  13. }
  14.  
  15. int main()
  16. {
  17.  
  18.     int tam, i;
  19.  
  20.     double *v, cont=0, media;
  21.  
  22.     scanf("%d",&tam);
  23.  
  24.     v=(double*)malloc(tam*sizeof(double));
  25.  
  26.     for (i=0; i<tam; i++)
  27.     {
  28.  
  29.         //essa é a parte que voce precisa implementar: v[i]=le_numero();
  30.  
  31.         v[i]=le_numero();
  32.  
  33.         cont=cont+v[i];
  34.  
  35.     }
  36.  
  37.     media=cont/tam;
  38.  
  39.     printf("%.2lf\n",media);
  40.  
  41.     return 0;
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement