首页 > 代码库 > python 冒泡排序,递归

python 冒泡排序,递归


冒泡排序:

li = [33, 55, 58, 66, 58, 555,20000000000000000000000, 5555,5555, 5, 6, 62,1]


for i in range(1,len(li)):
for l in range(len(li)-i):
if li[l] >li[l+1]:
temp =li[l]
li[l]=li[l+1]
li[l+1]= temp
print(li)


递归:

斐波那契数列指的是这样一个数列 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368...

def func(arg1,arg2,n):
if n == 10:
print(arg1)
return (arg1, arg2)
arg3 = arg1 + arg2
func(arg2, arg3,n+1)

func(0,1,1)
 
 
 

python 冒泡排序,递归