有三个整数a,b,c.由键盘输入,输出其中最大的数
时间: 2023-05-29 14:06:58 浏览: 138
以下是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)
```
输入三个整数后,程序会分别比较它们的大小,输出最大的数。
相关问题
用c++写一个有三个整数a.b.c由键盘输入,输出其中最大的数
以下是用 C 语言编写的程序,可以实现输入三个整数 a、b、c,然后输出其中最大的数:
```c
#include <stdio.h>
int main() {
int a, b, c;
printf("请输入三个整数:\n");
scanf("%d%d%d", &a, &b, &c);
int max = a;
if (b > max) {
max = b;
}
if (c > max) {
max = c;
}
printf("最大的数是:%d\n", max);
return 0;
}
```
注意,这个程序只能处理整数,如果输入的是小数或其他类型的数据,程序可能会出错。
有三个整数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)