Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int compare(const void *a, const void *b)
- {
- return *(double*)a-*(double*)b;
- }
- double min_max_avg(double *min, double *max, int n, ...) // te trzy kropki na koncu nie sluza do wypelnienia jakby ktos nie wiedzial :P
- {
- double *tab=malloc(n*sizeof(double));
- if(!tab){
- printf ("BLAD!!\n");
- return -1;
- }
- va_list argptr;
- va_start (argptr,n);
- int i=0;
- double sum=0;
- for(;i<n;i++) {
- tab[i] = va_arg (argptr,double);
- sum += tab[i];
- }
- qsort(tab,n,sizeof(double),compare);
- *min=tab[0];
- *max=tab[n-1];
- va_end (argptr);
- printf("min=%lf max=%lf srednia=%lf",*min,*max,sum/n);
- return sum/n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement