输入3个整数,输出其中最大的数。
时间: 2024-05-05 22:20:49 浏览: 14
好的,以下是 Python 代码实现:
```
a, b, c = map(int, input().split())
max_num = max(a, b, c)
print(max_num)
```
首先使用 `input()` 函数获取用户输入的三个整数,然后使用 `split()` 函数将用户输入的字符串按照空格分隔成三个字符串,并使用 `map()` 函数将这三个字符串转换为整数类型。最后使用 `max()` 函数获取三个整数中的最大值,并输出即可。
相关问题
输入3个整数输出其中最大数
我可以回答这个问题。请看以下代码:
```lua
function max(a, b, c)
if a >= b and a >= c then
return a
elseif b >= a and b >= c then
return b
else
return c
end
end
print(max(1, 2, 3)) -- 输出 3
```
这段代码可以输入三个整数,然后输出其中最大的数。
输入三个整数输出其中最大的数
好的,可以使用以下的 Python 代码实现:
```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)
```
你可以输入三个整数,程序会输出其中最大的数。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)