function cfind_median8, nn, arr return, median(arr[0:nn-1]) end ;/* ---------------------------------------------------------------------- ; Find median of an array of double (8 byte real) numbers. ; Input: arr[] (array of values which will be sorted). ; nn (number of elements in the array). ; Returns the median value. ;*/ ;/*@@*/ ;double cfind_median8(int nn, double arr[] ) ;{ ;/**/ ;double median; ;int kk; ;/**/ ;/* Check. */ ;if (nn < 1) { return(0.); } ;/* Sort the array. */ ;cqcksrt8(nn,arr); ;kk = (nn/2); ;if ((nn%2) == 0) { ; median = ( arr[kk] + arr[(kk-1)] ) / 2.; /* Even number of elements. */ ;} else { ; median = arr[kk]; /* Odd number of elements. */ ;} ;return(median); ;} ;