#include <iostream>
using namespace std;
int main()
{
//输入3只猪的重量得出哪只猪最重
int pig_a = 0;
int pig_b = 0;
int pig_c = 0;
cout << "请录入猪A的重量" << endl;
cin >> pig_a;
cout << "请录入猪B的重量" << endl;
cin >> pig_b;
cout << "请录入猪C的重量" << endl;
cin >> pig_c;
cout << "猪A的重量是:" << pig_a << endl;
cout << "猪B的重量是:" << pig_b << endl;
cout << "猪C的重量是:" << pig_c << endl;
//如果A比B和C都重,那A最重
if (pig_a > pig_b)
{
if (pig_a > pig_c)
{
cout << "------------" << "---" << "----" << endl;
cout << "猪A是最重的" << pig_a << "KG" << endl;
}
else
{
cout << "------------" << "---" << "----" << endl;
cout << "猪C是最重的" << pig_c << "KG" << endl;
}
}
else
{
if (pig_b > pig_c)
{
cout << "------------" << "---" << "----" << endl;
cout << "猪B是最重的" << pig_b << "KG" << endl;
}
else
{
cout << "------------" << "---" << "----" << endl;
cout << "猪C是最重的" << pig_c << "KG" << endl;
}
}
//如果B比A和C都重,那B最重
//如果C比A和B都重,那C最重
system("pause");
return 0;
}
学习日记 算出最重的哪一只
最新推荐文章于 2024-05-02 20:41:48 发布