首页 > 编程语言 > 详细

c++程序—if语句实践

时间:2020-02-28 00:08:20      阅读:84      评论:0      收藏:0      [点我收藏+]

三只小

#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;

}

 

猪谁最重

 

c++程序—if语句实践

原文:https://www.cnblogs.com/hackerteen/p/12375232.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!