Determine the largest number among three numbers using C++

后端 未结 5 1420
暖寄归人
暖寄归人 2021-01-19 23:20

How can I determine the largest number among three numbers using C++?

I need to simplify this

 w=(z>((x>y)?x:y)?z:((x>y)?x:y));
5条回答
  •  春和景丽
    2021-01-19 23:32

    Use the simple if condition

    int w = x;
    
    if(y > w)
      w = y;
    if(z > w)
      w = z;
    

    Where w is the max among three.

提交回复
热议问题