- 费罗列算法
def test(num):
i=0
st=1
end=1
tem=1
while i <=num:
i+=1
if i <=2:
print(tem)
else:
tem = st+end
st=end
end=tem
2.冒泡 排序
def test(l_list):
for i in range(len(l_list)):
for j in range(len(l_list)-i-1):
if l_list[j] > l_list[j+1]:
l_list[j],l_list[j+1] = l_list[j+1],l_list[j]
- 快排
拿出第一个数为标准,比它小的排左边,比它大的排右边,循环操作
```python
def test(l):
if len(l)<=2:
return l
else:
tem = l[0]
less = [i for i in l[1:] if i<=tem]
greater = [i for i in l[1:] if i>tem]
return test(less) + [tem] + test(greater)
```
- 插入
def test(l):
for i in range(1,len(l)):
cur = l[i]
j=i
while l[j-1]<cur and j>=0:
l[j] = l[j-1]
j-=1
l[i]=cur
return l