looking for max function that decides from 3 arguments

This is a discussion on looking for max function that decides from 3 arguments within the C Programming forums, part of the General Programming Boards category; Hello to all, Does anyone know of a C function that will take the max value from a collection of ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    77

    looking for max function that decides from 3 arguments

    Hello to all,

    Does anyone know of a C function that will take the max value from a collection of arguments,

    for instance,

    { s(j-1,k)
    s(j,k) = max { s(j,k-1)
    {s(j-1,k-1)



    Any suggestions would be great

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Once you write one, there will be one.

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    77
    is there a standard function for computing max; such as strlen and strstr are standard functions?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by gkoenig View Post
    is there a standard function for computing max; such as strlen and strstr are standard functions?
    fmax, but it only takes two arguments.

  5. #5
    Registered User
    Join Date
    Feb 2008
    Posts
    77
    thanks. Any advice on how to start my own subroutine that will take the max from 3 arguments?

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I would start it like this:
    Code:
    double max_three(double x, double y, double z)
    It should probably have four if statements in it. Edit: Or, alternatively, two calls to fmax.

    If you plan to do three, and four, and five, etc.... then maybe you should look at taking the maximum of an arbitrary number of elements (passed in as a parameter, of course).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sending multiple arguments to function..
    By Zzaacchh in forum C++ Programming
    Replies: 3
    Last Post: 09-06-2008, 03:20 PM
  2. Arrays as function arguments :(
    By strokebow in forum C Programming
    Replies: 10
    Last Post: 11-18-2006, 02:26 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 06:18 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21