in reply to Finding Median of an Array after an Infinite Loop
Could you show the code you've already got? See also How do I post a question effectively?
I just can't wrap my head around how to tell it to look at the middle numbers without knowing beforehand how many numbers will be input into the array.
But after the loop ends you know how many elements the array contains. Using the array in scalar context will return the number of elements it contains, and $#array will return the index of the last element (-1 if the array is empty) - see perlintro. So that should be enough info to help you find the middle element, I think?
|
|---|