利用c语音编程编程利用if和for语句实现三个aa和一个bb,循环显示
发布网友
发布时间:2023-03-07 10:19
我来回答
共1个回答
热心网友
时间:2023-10-06 10:34
def MergeSort(lists):
if len(lists) <= 1:
return lists
num = int( len(lists)/2 )
left = MergeSort(lists[:num])
right = MergeSort(lists[num:])
return Merge(left, right)
def Merge(left,right):
r, l=0, 0
result=[]
while l<len(left) and r<len(right):
if left[l] < right[r]:
result.append(left[l])
l += 1
else:
result.append(right[r])
r += 1
result += right[r:]
result+= left[l:]
return result
print MergeSort([1, 2, 3, 4, 5, 6, 7, 90, 21, 23, 45])