Find all combinations of a given set of numbers

前端 未结 9 1649
故里飘歌
故里飘歌 2020-12-03 09:30

say I have a set of numbers \'0\', \'1\', \'2\', ..., \'9\'. I want to find all numbers that contain exactly one of each of the numbers in my set.

The problem is: Be

9条回答
  •  猫巷女王i
    2020-12-03 09:45

    To me, it looks like you are looking for all permutations of a given set of elements.

    If you use C++ there is a standard function next_permutation() that does exactly what you are looking for. You start with the sorted array and then call next_permutation repeatedly.

    The example is here: http://www.cplusplus.com/reference/algorithm/next_permutation/

提交回复
热议问题