📜  嵌套条件运算符 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:53.734000             🧑  作者: Mango

代码示例1
cout << "Execute expression using "
    << "ternary operator: ";
    int a = 2 > 3 ? 2 : 3 > 4 ? 3 : 4;
    cout << a << endl;
      
    cout << "Execute expression using "
    << "if else statement: ";
    if ( 2 > 3 )
        cout << "2";
    else if ( 3 > 4 )
        cout << "3";
    else 
        cout << "4";