1 Star 0 Fork 2

Asheng/python100

forked from Yonja/python100 
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
python67.py 772 Bytes
Copy Edit Raw Blame History
zhangweizhi authored 2016-06-04 15:16 +08:00 . the 100 theme
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。
"""
def inp(numbers,num):
for i in range(num):
numbers.append(int(raw_input('input a number:\n')))
def max_min(array,p):
max = min =0
for i in range(1,len(array) - 1):
p = i
if array[p] > array[max]:max = p
elif array[p] < array[min]:min = p
k = max
l = min
array[0],array[k] = array[k],array[0]
array[num - 1],array[l] = array[l],array[num - 1]
def outp(numbers):
for i in range(len(numbers)):
print numbers[i]
if __name__ == '__main__':
array = []
num = 4
p = 0
inp(array,num)
max_min(array,p)
outp(array)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Asheng008/python100.git
git@gitee.com:Asheng008/python100.git
Asheng008
python100
python100
master

Search