用Python写一个程序,输入的第一行为整数n,表示整数数列中的个数。第二行包含n个正整数。如果第二行的n个正整数的中间数存在,也输出中间数的值,否则输出-1表示不存在中间数
时间: 2023-05-21 14:03:33 浏览: 114
以下是Python程序的代码:
n = int(input())
nums = list(map(int, input().split()))
nums.sort()
if n % 2 == 1:
middle = nums[n // 2]
print(middle)
else:
print(-1)
希望这个程序能够帮助你解决问题!
相关推荐
![cpp](https://img-home.csdnimg.cn/images/20210720083646.png)
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![apk](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![m](https://img-home.csdnimg.cn/images/20210720083646.png)