C++ 程序:求三个数中最大值

原文:https://www.studytonight.com/cpp-programs/program-to-find-greatest-of-three-numbers-in-cpp

下面是找出三个数字中最大值的程序。

#include<iostream.h>
#include<conio.h>

int main()
{
    float n1, n2, n3;
    cout << "Enter three numbers: ";
    cin >> n1 >> n2 >> n3;
    if (n1 >= n2 && n1 >= n3)
    {
        cout << "Largest number: " << n1;
    }
    if(n2 >= n1 && n2 >= n3)
    {
        cout << "Largest number: " << n2;
    }
    if(n3 >= n1 && n3 >= n2)
    {
        cout << "Largest number: " << n3;
    }
    getch();
    return 0;
}

输入三个数字:34 45 56 最大数字:56