C语言输入三个数,求最大值
时间: 2023-09-26 13:11:37 浏览: 139
可以使用 if 条件语句来判断三个数的大小关系,进而找出最大值。示例如下:
```c
#include <stdio.h>
int main() {
int a, b, c;
printf("请输入三个整数:\n");
scanf("%d %d %d", &a, &b, &c);
if (a >= b && a >= c) {
printf("最大值为:%d\n", a);
} else if (b >= a && b >= c) {
printf("最大值为:%d\n", b);
} else {
printf("最大值为:%d\n", c);
}
return 0;
}
```
在上述代码中,我们先通过 `scanf` 函数输入三个整数,然后通过 if 条件语句判断每个数与其他两个数的大小关系,进而找出最大值并输出。
阅读全文
相关推荐
![c](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)