c++“三只小猪问题“用if语句实现
作者:互联网
复习c++ day01 关于if语句复习
#include<iostream>
using namespace std;
int main()
{
int num1 = 0;
int num2 = 0;
int num3 = 0;
cout<<"输入小猪a的体重"<<endl;
cin>>num1;
cout<<"输入小猪b的体重"<<endl;
cin>>num2;
cout<<"输入小猪c的体重"<<endl;
cin>>num3;
if(num1<num2){
if(num3>num2){
cout<<"小猪c体重最重"<<endl;
}else{
cout<<"小猪b体重最重"<<endl;
}
}else{
if(num1>num3){
cout<<"小猪a体重最重"<<endl;
}else{
cout<<"小猪c体重最重"<<endl;
}
}
}
运行结果
标签:语句,小猪,num2,num3,int,c++,num1,cout 来源: https://blog.csdn.net/weixin_46256535/article/details/116033473