right, you are treating the ordered array like it is an ordered binary tree, which is okay for finding the max element. But without pointers and/or using some recursion, you'll have a very messy solution.
The problem is you want to find the first the element that is closest to X, but not greater then it. I think, it would do to simply linearly search, starting from the greatest element and then continue backwards until you find the element that meets this condition.
that's what i did. then you end that loop, and start another one.
matt
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only