none
Maximum of a list of numbers RRS feed

  • Question

  • Well as the tittle says could anyone help me do this?

    Like if i have 11 variables, get the highest one..

    thanks

    Saturday, September 3, 2011 9:58 AM

Answers

  • The easiest would be to loop through an array of the numbers, and check if each is larger than your current max, then if it is update the current maximum.

    Here is some pseudo-code (the logic of the code in words)

    set the current max to a small number

    loop through each number

        if the current number is larger than current max then set the current max to this number

    loop on the next number in the list

    the current max will be the largest number in the list

    Have a go and post any problems with the code you are using.

    • Marked as answer by Luquitas94 Saturday, September 3, 2011 10:57 AM
    Saturday, September 3, 2011 10:04 AM
    Moderator
  • ok thanks that's what i thought but what i was really asking was if there was a built-in tool... thanks anyway XD

    FVN009

     

     

    • Marked as answer by Luquitas94 Saturday, September 3, 2011 10:57 AM
    Saturday, September 3, 2011 10:57 AM

All replies

  • The easiest would be to loop through an array of the numbers, and check if each is larger than your current max, then if it is update the current maximum.

    Here is some pseudo-code (the logic of the code in words)

    set the current max to a small number

    loop through each number

        if the current number is larger than current max then set the current max to this number

    loop on the next number in the list

    the current max will be the largest number in the list

    Have a go and post any problems with the code you are using.

    • Marked as answer by Luquitas94 Saturday, September 3, 2011 10:57 AM
    Saturday, September 3, 2011 10:04 AM
    Moderator
  • ok thanks that's what i thought but what i was really asking was if there was a built-in tool... thanks anyway XD

    FVN009

     

     

    • Marked as answer by Luquitas94 Saturday, September 3, 2011 10:57 AM
    Saturday, September 3, 2011 10:57 AM