Advertisement
Infernale

Summary

Dec 14th, 2018
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     FILE *input = fopen("testdata.in", "r");
  5.     long long data[1005], n=0, sum=0, min=1000005, max=0;
  6.     do{
  7.         if(fscanf(input, "%lld", &data[n])==1){
  8.             min = (data[n]<min?data[n]:min);
  9.             max = (data[n]>max?data[n]:max);
  10.             sum+=data[n++];
  11.         }
  12.     }while(!feof(input));
  13.     fclose(input);
  14.     printf("Count : %lld\n", n);
  15.     printf("Sum   : %lld\n", sum);
  16.     printf("Mean  : %.2f\n", (double)sum/n);
  17.     printf("Min   : %lld\n", min);
  18.     printf("Max   : %lld\n", max);
  19.     printf("Range : %lld\n", max-min);
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement