发布网友
共1个回答
热心网友
#python2下的代码:
test=input('请输入一个数组:')
temp=sorted(test)
print '从小到大排序得:',temp
print '您输入的数组中,最大的数为:%g'%temp[-1]
print '您输入的数组中,第二大大的数为:%g'%temp[-2]
'------------------------------------'
#python3下的代码:
test=input('请输入一个数组:')
temp=[]
for i in test.split(','):
temp.append(int(i))
temp=sorted(temp)
print('从小到大排序得:',temp)
print('您输入的数组中,最大的数为:%g'%temp[-1])
print('您输入的数组中,第二大大的数为:%g'%temp[-2])