问题
Can someone help me convert this line to an if-else statement?
temp = head->left ? head->left : head->right;
Thanks!
回答1:
if ( head->left )
temp = head->left;
else
temp = head->right;
回答2:
if (head->left)
{
temp = head->left;
}
else
{
temp = head->right;
}
来源:https://stackoverflow.com/questions/22976190/c-ternary-operate-to-if-else