有3个整数a b c,由键盘输入,输出其中最大的数。
时间: 2023-05-18 18:02:54 浏览: 79
C知道:您好!以下是您需要的答案:
可以使用 if-else 语句来比较三个数的大小,具体代码如下:
#include <stdio.h>
int main() {
int a, b, c, max;
printf("请输入三个整数:\n");
scanf("%d %d %d", &a, &b, &c);
if (a > b) {
max = a;
} else {
max = b;
}
if (c > max) {
max = c;
}
printf("最大的数是:%d\n", max);
return 0;
}
如果您有其他问题,欢迎随时提出。
相关问题
有3个整数a,b,c由键盘输入,输出其中最大的数
以下是Python代码实现:
```
a = int(input("请输入第一个整数:"))
b = int(input("请输入第二个整数:"))
c = int(input("请输入第三个整数:"))
if a > b and a > c:
print("最大的数是:", a)
elif b > a and b > c:
print("最大的数是:", b)
else:
print("最大的数是:", c)
```
以下是示例输出:
```
请输入第一个整数:5
请输入第二个整数:8
请输入第三个整数:3
最大的数是: 8
```
有三个整数a b c,由键盘输入,输出其中的最大的数
可以使用以下代码实现:
a = int(input("请输入整数a:"))
b = int(input("请输入整数b:"))
c = int(input("请输入整数c:"))
if a > b and a > c:
print("最大的数是:", a)
elif b > a and b > c:
print("最大的数是:", b)
else:
print("最大的数是:", c)