'''
输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。
'''
l=[2,5,4,6,20,1,10]
big=0
bb=0
small=10000000000000
ss=0
one=0
last=0
a=int(len(l))
b=a-1
for i in range(len(l)):
if(l[i] > big):
big=l[i]
bb=i
print 'The larger is l[%d] = %d' % (bb,big)
for j in range(len(l)):
if(l[j] < small):
small=l[j]
ss=j
print 'The smaller is l[%d] = %d' % (ss,small)
print l
one=l[0]
l[0]=big
l[bb]=one
last=l[b]
l[b]=small
l[ss]=last
print l
阅读(3106) | 评论(0) | 转发(0) |