1 Star 0 Fork 1

llongger/Code_C++

forked from GodOuO/Code_C++ 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
01.three_pigs.cpp 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
GodOuO 提交于 2023-03-15 04:05 . Train
#include<iostream>
using namespace std;
int main(){
int a=0,b=0,c=0;
cout<<"Please input the weight of pigA:"<<endl;
cin>>a;
cout<<"Please input the weight of pigB:"<<endl;
cin>>b;
cout<<"Please input the weight of pigC:"<<endl;
cin>>c;
if(a<=0||b<=0||c<=0)
cout<<"ERROR!"<<endl;
else if((a>b&&c>a)||(b>a&&c>b))
cout<<"pigC is the heaviest!"<<endl;
else if((a>c&&b>a)||(c>a&&b>c))
cout<<"pigB is the heaviest!"<<endl;
else if((b>c&&a>b)||(c>b&&a>c))
cout<<"pigA is the heaviest!"<<endl;
else if(a==b&&a>c)
cout<<"pigA and pigB are the heaviest!"<<endl;
else if(a==b&&a<c)
cout<<"pigC is the heaviest!"<<endl;
else if(b==c&&b>a)
cout<<"pigB and pigC are the heaviest!"<<endl;
else if(b==c&&b<a)
cout<<"pigA is the heaviest!"<<endl;
else if(a==c&&a>b)
cout<<"pigA and pigC are the heaviest!"<<endl;
else if(a==c&&b>a)
cout<<"pigB is the heaviest!"<<endl;
else if(a==b&&b==c&&a==c)
cout<<"They have the same weight!"<<endl;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/llongger/codeCpp.git
git@gitee.com:llongger/codeCpp.git
llongger
codeCpp
Code_C++
master

搜索帮助