+ 11

Explain statement in C++?

I don't known the statement: (a>b?a>c?a:c:b>c?b:c) Thanks in advances.

10th Dec 2018, 5:49 AM
Nguyễn Văn Sơn
Nguyễn Văn Sơn - avatar
3 ответов
+ 12
Very interesting! (a > b) ? ( (a > c) ? a : c ) : ( (b > c) ? b : c ) Expanding: (a > b) ? (a > c) ? a : c : (b > c) ? b : c Equivalent: if (a > b) if (a > c) a else c else if (b > c) b else c Always wrap the related blocks in parenthesis to make it readable.
10th Dec 2018, 6:15 AM
Babak
Babak - avatar
+ 7
Condition is a>b?a>c? If true: ??? I do not understand .....
10th Dec 2018, 6:00 AM
Nguyễn Văn Sơn
Nguyễn Văn Sơn - avatar
+ 6
Ternary operator. Condition?If yes:If not
10th Dec 2018, 5:54 AM
ShortCode