+ 11
Explain statement in C++?
I don't known the statement: (a>b?a>c?a:c:b>c?b:c) Thanks in advances.
3 Respuestas
+ 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.
+ 7
Condition is a>b?a>c?
If true: ??? I do not understand
.....
+ 6
Ternary operator. Condition?If yes:If not