Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- FILE *input = fopen("testdata.in", "r");
- long long data[1005], n=0, sum=0, min=1000005, max=0;
- do{
- if(fscanf(input, "%lld", &data[n])==1){
- min = (data[n]<min?data[n]:min);
- max = (data[n]>max?data[n]:max);
- sum+=data[n++];
- }
- }while(!feof(input));
- fclose(input);
- printf("Count : %lld\n", n);
- printf("Sum : %lld\n", sum);
- printf("Mean : %.2f\n", (double)sum/n);
- printf("Min : %lld\n", min);
- printf("Max : %lld\n", max);
- printf("Range : %lld\n", max-min);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement