c++程序—if语句实践

三只小

#include<iostream>
using namespace std;
#include<string>

int main()
{
    //which pig is the biggest
    int num1 = 0;
    int num2 = 0;
    int num3 = 0;

    cout << "input pigA' weight" << endl;
    cin >> num1;

    cout << "input pigB' weight" << endl;
    cin >> num2;

    cout << "input pigC' weight" << endl;
    cin >> num3;

    if (num1 >= num2)
    {
        if (num1 >= num3)
            cout << "pigA is the biggest,it's weight is " <<num1<< endl;
        else
            cout << "pigC is the biggest,it's weight is " << num3<<endl;
    }
    else
    {
        if (num2 >= num3)
            cout << "pigB is the biggest,it's weight is " << num2 << endl;
        else
            cout << "pigC is the biggest,it's weight is " << num3 << endl;
    }


    
    system("pause");
    return 0;

}

 

猪谁最重

 

posted @ 2020-02-27 23:28  Jackie_Wang  阅读(637)  评论(0编辑  收藏  举报