def Permutation(str, beg, endl): if beg == endl - 1: print(str) return for i in range(beg, endl): if str[i] in str[beg:i]: continue str[i], str[beg] = str[beg], str[i] Permutation(str, beg+1, endl) str[beg], str[i] = str[i], str[beg] a = '1223' a = list(a) beg = 0 endl = len(a) Permutation(a, beg, endl)
python 字符串(y有重复)全排列算法
最新推荐文章于 2023-01-04 15:10:21 发布