input: A list of numbers from the keyboard. output: The median of the input numbers
I need the whole code
def median(array)
array.sort!
if (array.length % 2==1 )
return array[array.length/2.0]
else
return (array[array.length/2] + array[(array.length/2)-1])/2.0
end
end
How can I enter list from keyboard and the find the median?