4、将数组的奇数放在前,偶数放在后
2017-09-29 本文已影响0人
i7990X
def part(lists):
i=0
j=len(lists)-1
while i<j:
while i<j and lists[i]%2==1:
i+=1
while i<j and lists[j]%2==0:
j-=1
if i<j:
lists[i],lists[j]=lists[j],lists[i]
return lists