Isn't this really 9 Boolean tests? Since the '&&' operator is 'a*b=true\false'? :p Not trying to one up you just pointing out that this is even more inefficent then previously thought.
I'm not sure if j's challenge was meant for all of us beginners, but I decided to give it a shot:
1 2 3 4 5 6
int GetLargest(int a, int b, int c)
{
return (a>b) ? // Is a greater than b?
((a>c) ? a : c) // Yes - but is a > c? If yes, return a, otherwise return c.
: ((b>c) ? b : c); // No - hence b>=a. Is b > c? If yes, return b, otherwise return c.
}
if (a>b)
{
if (a>c)
{ return a;}
}
if (b>c)
{return b;}
else
{return c;}
Yes technically there are three boolean operators, but your system only ever runs two comparisons before assuming that 'c' is the largest variable.
EDIT: Never mind this is what sammy34 did but he didn't point out that the system only runs to comparisons so I had to *ugh* read the code to see it :p.