if the numbers are non-zero integers we can do this:
first, convert all the numbers to unsigned integers. This will get us rid of negative numbers.
then, if floor(x / y) = 0, x < y
then just do:
Code:
int max(int x, int y)
{
unsigned signx = (unsigned)x;
unsigned signy = (unsigned)y;
if ( !(signx / signy) )
return y;
return x;
}
int main()
{
int x, y, z;
scanf("%d %d %d", &x, &y, &z);
printf("%d", max(max(x, y), z));
return 0;
}
If the numbers can be 0, one way would be to check the denominator. If it is 0, return the other number:
Code:
int max(int x, int y)
{
// 1 = negative, 0 = positive
unsigned signx = (unsigned)x;
unsigned signy = (unsigned)y;
if ( signy )
if ( !(signx / signy) )
return y;
return x;
}