C语言用条件表达式输出三个整数中的最大值
时间: 2023-05-17 12:04:40 浏览: 209
可以使用以下代码实现:
```c
#include <stdio.h>
int main() {
int a, b, c, max;
printf("请输入三个整数:\n");
scanf("%d %d %d", &a, &b, &c);
max = a > b ? (a > c ? a : c) : (b > c ? b : c);
printf("最大值是:%d\n", max);
return 0;
}
```
这段代码使用条件表达式判断三个整数中的最大值,并输出结果。
相关问题
c语言用条件表达式实现输入三个整数中的最大值
可以使用以下代码实现:
```c
#include <stdio.h>
int main() {
int a, b, c, max;
printf("请输入三个整数:\n");
scanf("%d %d %d", &a, &b, &c);
max = a > b ? (a > c ? a : c) : (b > c ? b : c);
printf("最大值为:%d\n", max);
return 0;
}
```
这段代码使用了条件表达式来判断三个整数中的最大值,并输出结果。
用C语言编程,输入3个整数,输出其中的最大值,要求只能使用条件表达式
```c
#include <stdio.h>
int main() {
int a, b, c, max;
printf("请输入三个整数:");
scanf("%d %d %d", &a, &b, &c);
max = a > b ? (a > c ? a : c) : (b > c ? b : c);
printf("最大值为:%d", max);
return 0;
}
```
阅读全文
相关推荐
















