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
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement