1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > c++ if-else 实现比较三只小猪体重

c++ if-else 实现比较三只小猪体重

时间:2019-02-11 18:19:58

相关推荐

c++ if-else 实现比较三只小猪体重

输入三只小猪的体重,输出最重的小猪是哪只.

code

#include <iostream>using namespace std;int main(){int pigone = 0;int pigtwo = 0;int pigthree = 0;cout << "LYQ家有三只小猪,L,Y和Q,今天LYQ同学想比较一下它们的体重,它们分别重" << endl;cin >> pigone >> pigtwo >> pigthree;if (pigone > pigtwo) {if (pigone > pigthree) {cout << "L最胖" << endl;}else cout << "Q最胖" << endl;}else if (pigtwo > pigthree) {cout << "Y最胖" << endl;}else cout << "Q最胖" << endl;system("pause");return 0;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。