开发者

How do I generate all permutations of a list of numbers?

开发者 https://www.devze.com 2023-01-26 15:20 出处:网络
Ho开发者_JAVA百科w do I generate all possible permutations of a list of numbers in C? As an example, [1, 8, 12] would generate

Ho开发者_JAVA百科w 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消