Embedded_game/人工智能赛项/waste.py

9 lines
241 B
Python
Raw Permalink Normal View History

2025-01-02 12:48:11 +08:00
def bubbleSort(arr):
for i in range(1,len(arr)):
for j in range(0,len(arr)-i):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
return arr
nums = [1,3,2,4,6]
print(bubbleSort(nums))