从键盘上输入三个数,求出其中的最大值,并输出(用三项条件运算符完成) c++程序

如题所述

第1个回答  2014-03-29
#include <iostream>
using namespace std;
int main()
{
    int a, b, c;
    cout << "输入三个数:"<<endl;
    cin >>a;
    cin >> b;
    cin >> c;
    
    int max1 = a > b ? a : b;
    
    int max2 = max1 > c ? max1 :c;
    
    cout << "最大数: "+ max2 << endl;
    
    return 0;
    
}