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

和自甴很熟 提交于 2019-12-18 08:56:49

问题


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], ...

回答1:


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



来源:https://stackoverflow.com/questions/4270805/how-do-i-generate-all-permutations-of-a-list-of-numbers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!