Advertisement
luizaspan

Média, máx e min (vetor)

May 28th, 2015
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define N 15
  4.  
  5. int main(void)
  6. {
  7.   int n,min,max,data[N],i;
  8.   double media;
  9.  
  10.   for(i=0;i<N;i++)
  11.     scanf("%d",&data[i]);
  12.  
  13.   media=max=min=data[0];
  14.  
  15.   for(n=1;n<N;n++)
  16.     {
  17.       if (data[n]<min) min=data[n];
  18.       if (data[n]>max) max=data[n];
  19.       media+=data[n];
  20.     }
  21.  
  22.   media/=N;
  23.  
  24.   printf("%d %d %lf \n",min,max,media);
  25.  
  26.   return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement