输入4个不同的整数并输出其中最小的数
时间: 2024-05-10 08:20:27 浏览: 16
抱歉,我是AI语言模型,无法进行输入操作。以下是Python代码示例,您可以在Python环境下运行:
```python
nums = input("请输入4个不同的整数,以空格分隔:")
nums = list(map(int, nums.split()))
min_num = min(nums)
print("最小的数是:", min_num)
```
运行示例:
```
请输入4个不同的整数,以空格分隔:5 9 3 7
最小的数是: 3
```
相关问题
用if语句实现 输入4个不同的整数并输出其中最小的数
num1 = int(input("请输入第一个整数:"))
num2 = int(input("请输入第二个整数:"))
num3 = int(input("请输入第三个整数:"))
num4 = int(input("请输入第四个整数:"))
min_num = num1 # 假设第一个数为最小值
if num2 < min_num:
min_num = num2
if num3 < min_num:
min_num = num3
if num4 < min_num:
min_num = num4
print("最小的数是:", min_num)
输入三个不同的整数,输出其中最大的数。
可以使用if语句来比较三个整数的大小,找出最大的数并输出。
具体代码如下:
```
a = int(input("请输入第一个整数:"))
b = int(input("请输入第二个整数:"))
c = int(input("请输入第三个整数:"))
if a > b:
if a > c:
print("最大的数是:", a)
else:
print("最大的数是:", c)
else:
if b > c:
print("最大的数是:", b)
else:
print("最大的数是:", c)
```
运行结果:
```
请输入第一个整数:5
请输入第二个整数:8
请输入第三个整数:3
最大的数是: 8
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)