且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何生成号码列表的所有排列?

更新时间:2022-10-17 19:51:30

有一个看这个的·约翰逊·特罗特算法与Applet是你想要什么。

How do I generate all possible permutations of a list of numbers in C?

As an example, [1, 8, 12] would generate

[1, 12, 8],
[12, 8, 1],
[12, 1, 8], ...

Have a look at this Johnson-Trotter Algorithm and applet it is exactly what you want.