该程序获取 3 个数字并找出其中最大的一个。为此,我们将相互比较数字并找出最大的
Input: a=2,b=4,c=7
Output:7 Largest Number
说明
该程序仅使用 if 语句来查找最大数。
示例
#include <iostream>
using namespace std;
int main() {
int a,b,c;
a=2,b=4,c=7;
if(a>b) {
if(a>c) {
printf("%d Largest Number ",a);
} else {
printf("%d Largest Number ",c);
}
} else {
if(b>c) {
printf("%d Largest Number ",b);
} else {
printf("%d Largest Number ",c);
}
}
return 0;
}