3 ms·
r[0] = Min( a, Min( b, c ) ) r[2] = Max( a, Max( b, c ) ) r[1] = a + b + c - r[0] - r[2] I don't think that can suffer from integer overflow. But it might
by palish 16y ago
r[0] = Min( a, Min( b, c ) )
r[2] = Max( a, Max( b, c ) )
r[1] = a + b + c - r[0] - r[2]
I don't think that can suffer from integer overflow. But it might suffer from floating-point rounding problems.
Of course you could always go with the boring solution:
if a > b: swap( a, b )
if b > c: swap( b, c )
if a > b: swap( a, b )