Hey I want to create a max function that does the same thing as the c++ max function counterpart does, but the only way I can see to do it is to compare each number with everyother number. Of course if its only two numbers then you can just compare them using blt or bgt then jumping to one target if number A is larger and printing it out, or jumping to another target is B is larger and printing that out, but how would you do it for a list of numbers I can't think think of a more efficient way then having to compare every number in the list to eachother to determine the largest one.

You only need to traverse the list once. Set your "current max" to the first element in the list. For the remaining elements of the list, test each one against the "current max". If greater, set the "current max" to the current element.

[edit] Removed. I was still on x86 opcodes from the last question... [/edit]

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.