用C语言编写比较三个数的大小
时间: 2023-03-27 08:05:08 浏览: 124
你好,我可以回答这个问题。以下是用 C 语言编写比较三个数大小的代码:
```
#include <stdio.h>
int main() {
int a, b, c;
printf("请输入三个整数:\n");
scanf("%d %d %d", &a, &b, &c);
if (a > b) {
if (a > c) {
printf("%d 最大\n", a);
} else {
printf("%d 最大\n", c);
}
} else {
if (b > c) {
printf("%d 最大\n", b);
} else {
printf("%d 最大\n", c);
}
}
return ;
}
```
希望能对你有所帮助。
相关问题
用C语言编写一个程序比较三个数大小
可以使用以下代码实现:
```c
#include <stdio.h>
int main() {
int a, b, c;
printf("请输入三个整数,用空格分隔:");
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;
}
```
程序运行时会提示用户输入三个整数,然后通过 if 语句判断哪一个数最大,并输出结果。
用c语言编写三个整数比大小
以下是用 C 语言编写三个整数比大小的代码:
```
#include <stdio.h>
int main() {
int a, b, c;
printf("请输入三个整数,以空格分隔:");
scanf("%d %d %d", &a, &b, &c);
if (a >= b && a >= c) {
printf("%d 是最大的整数", a);
}
else if (b >= a && b >= c) {
printf("%d 是最大的整数", b);
}
else {
printf("%d 是最大的整数", c);
}
return 0;
}
```
希望这个代码可以帮到您!
相关推荐
![java](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)