编写程序用if -else分支结构语句求abc三个数中最大的数并将其放在变量max中输出max用C语言写
以下是用C语言编写的程序:
#include <stdio.h>
int main() {
int a, b, c;
int max;
printf("请输入三个整数:");
scanf("%d %d %d", &a, &b, &c);
if (a > b && a > c) {
max = a;
} else if (b > a && b > c) {
max = b;
} else {
max = c;
}
printf("最大的数是:%d\n", max);
return 0;
}
运行程序后,会提示用户输入三个整数,然后程序会根据if-else分支结构语句判断出最大的数,并将其放在变量max中,最后输出max。
原文地址: http://www.cveoy.top/t/topic/i7pn 著作权归作者所有。请勿转载和采集!