输入3个整数,求最大数并输出,用c语言
时间: 2023-06-02 20:01:59 浏览: 52
#include <stdio.h>
int main() {
int a, b, c, max;
printf("请输入三个整数:\n");
scanf("%d %d %d", &a, &b, &c);
max = a;
if (b > max) {
max = b;
}
if (c > max) {
max = c;
}
printf("最大数为:%d\n", max);
return 0;
}
相关问题
输入三个整数,求其最大值并输出。c语言
好的,以下是求三个整数最大值的C语言代码:
```c
#include <stdio.h>
int main() {
int a, b, c, max;
printf("请输入三个整数:\n");
scanf("%d %d %d", &a, &b, &c);
max = a;
if (max < b) {
max = b;
}
if (max < c) {
max = c;
}
printf("最大的数为:%d", max);
return 0;
}
```
在这个程序中,我们首先声明了三个整数变量 `a`、`b`、`c`,以及一个用于存储最大值的变量 `max`。接着,我们使用 `scanf` 函数从标准输入中读取三个整数,并将它们赋值给变量 `a`、`b`、`c`。然后,我们将 `max` 的初始值设为 `a`,并通过两个 `if` 语句来找出最大值。最后,我们使用 `printf` 函数输出最大值。
希望这个代码能够帮助到你!
输入三个整数,求其中的最大值并输出C语言
好的,以下是代码实现:
```c
#include <stdio.h>
int main() {
int a, b, c, max;
printf("请输入三个整数:\n");
scanf("%d %d %d", &a, &b, &c);
max = a;
if (b > max) {
max = b;
}
if (c > max) {
max = c;
}
printf("最大值为:%d\n", max);
return 0;
}
```
注:以上代码可以从用户处输入三个整数,然后通过比较得到最大值并输出。
相关推荐
![c](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)