def bubble():
b=list(map(int,input("十个数值:").split(",")))
for i in range(1,11):
for j in range(1,10):
if b[j-1]>b[j]:
temp=b[j-1]
b[j-1]=b[j]
b[j]=temp
print("冒泡排序的结果:")
return b
print(bubble())
结果:
def bubble():
b=list(map(int,input("十个数值:").split(",")))
for i in range(1,11):
for j in range(1,10):
if b[j-1]>b[j]:
temp=b[j-1]
b[j-1]=b[j]
b[j]=temp
print("冒泡排序的结果:")
return b
print(bubble())
结果: