문제

I need some help with writing such program which would read a .txt file containing large (but unknown) number of floating point numbers separated by whitespaces (name of the file has to be given by user) and calculate the size of the sample, max and min, mean, median and standart deviation.

Do i have to read the file and put it into array? Or is there another way?

Also I have to write this in C language.

도움이 되었습니까?

해결책

float x,i=~(257<<23),a,s,t;main(int n,char**f){a=-i;f=fopen(f[1],"r"
);for(n=0;fscanf(f,"%f",&x)>0;n++,s+=x,x<i?i=x:0,x>a?a=x:0,t+=x*x);
printf("%d %f %f %f %f\n",n,a,i,s/n,sqrtf(t/n));} 

Sorry for the long code. Didn't have time to make it shorter.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top