对于解释,我觉得以下这篇文章不错!
https://www.cnblogs.com/zyoung/p/6764371.html
python实现:
def AllRange(listx, start, end):
if start == end:
for i in listx:
print(i,end = '')
print()
for m in range(start,end+1):
listx[m],listx[start] = listx[start],listx[m]
AllRange(listx, start+1, end)
listx[m],listx[start] = listx[start],listx[m]
list1 = [1,2,3,4]
AllRange(list1,0, 3)