SỐ LỚN NHẤT TRONG 4 SỐ C++

#include<iostream>
using namespace std;
int main ()
{
    int a;
    int b;
    int c;
    int d;
    int max;
    cout<<"nhap vao bon so a,b,c,d: ";
    cin>>a>>b>>c>>d;
    if(a>b)
    {
        max = a;
        //cout<<"so lon nhat la "<<a;
    }
    else
    {
        max = b;
        //cout<<"so lon nhat la "<<b;
    }
    if(c > max)
    {
        max = c;
        //cout<<"so lon nhat la "<<c;
    }
    if(d > max)
    {
        max = d;
        //cout<<"so lon nhat la "<<d;
    }
    cout<<"So lon nhat la: "<<max;
//tuong tu nhu 3 so hay 2 so va nhieu hon
    return 0;
}    


KẾT QUẢ

Đăng nhận xét

0 Nhận xét