Jump to content

Averages/Median: Difference between revisions

m
(→‎{{header|Fortran}}: Using a supplied routine...)
Line 1,275:
end program Median_Test</lang>
 
If one refers to [[Quickselect_algorithm#Fortran]] which offers function FINDELEMENT(K,A,N) that returns the value of A(K) when the array of N elements has been rearranged if necessary so that A(K) is the K'th in order, then, supposing that a version is devised using the appropriate type for array A, <lang Fortran> K = N/2
MEDIAN = FINDELEMENT(K + 1,A,N)
IF (MOD(N,2).EQ.0) MEDIAN = (FINDELEMENT(K,A,N) + MEDIAN)/2 </lang>
1,220

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.