#coding=utf-8
"""
===========================
Author:杭州多测师_王sir
Time:2021-03-09 14:05
Wechat:xiaoshubass
website:www.duoceshi.cn
===========================
"""
def foo(s):
"""输入一个字符串,返回一个由这些字符组成的排列组合(递归思想)"""
if len(s) <=1:
return [s]
else:
list1 = []
for i in range(len(s)):
for _ in foo(s[:i] + s[i+1:]):
list1.append(s[i] + _)
return list1
if __name__ == "__main__":
str1 = foo('abcd')
print("排列组合数:%d" % len(str1))
print("排列组合数明细:%s" % str(str1))
# 冒泡排序
def sort(nums):
for i in range(len(nums) - 1): # 这个循环负责设置冒泡排序进行的次数
for j in range(len(nums) - i - 1): # j为列表下标
if nums[j] > nums[j + 1]:
nums[j], nums[j + 1] = nums[j + 1], nums[j]
return nums