Complex way !!! :
I'll point to the smallest with s; bigger with b; biggest with z.
U have 6 metods of arrangments:
1. s b w
2. s w b
3. b s w
4. b w s
5. w s b
6. w b s
use those numerical values as return values from the function;
Assume the three values are a,b and c:
use this: //I'll ignore the equality case.
Code:
===================================
if(a<b&&a<c)if(b<c)return 1;else return 2;
else if(b<a&&b<c)if(a<c)return 3;else return 4;
else if(c<a)return 5;else return 6;
===================================
Note that they are only 3 if statements :
the first: if(..)...else if(..)...else...
the second and the third are : if(..)...else...
Bookmarks