2012-01-20 54 views

回答

1

三個數字,尋找最小值和最大值。 然後查找既不是最小也不是最大值的數字:D

int a=100; 
int b=200; 
int c=300; 

int max = (a>b)? ((a>c)?a: (b>c)? b:c): ((b>c)?b: c); 
int min = (a<b)? ((a<c)?a: (b<c)? b:c): ((b<c)?b: c); 
int result = (a != min && a!= max)? a: (b !=min && b !=max)? b: c; 
相關問題