代码如下:
def bubble (data):
for i in range(7):
for j in range(i+1,8):
if data[i]>data[j]: #比较第i和第j个元素
data[i],data[j]=data[j],data[i]
data=[16,25,39,27,12,8,45,63]
bubble(data)
for i in range(8):
print('%d ' %data[i],end='')