c - Generating combinations of multiple sets -


I am looking for a non-recursive algorithm or C code so that all the combinations of all sets can be made (sure Not to mention that this is the correct scientific name). For example:

I have a set of N = 2 symbols:

  1 set: [A, Y, Z] 2 set: [1, Q] < / Code> 

should be output:

  A1 AQ Y1 YQ Z1 ZQ  

N may be different, the number of symbols Thanks in advance for any assistance in the special set of! :)

By algorithm:

We can create an integer array, whose Select length N, int [] to track [n] to see how many elements we have selected in all the lists. All elements are initially set to 0

Then we repeat those all arrows through a list of single links. If we have an element in the array i , then select [i] ++ , add it to the result when [i] == select the length of the array, So break and move on to the next array.

But I do not know that every time we repeat through an array, the size of the result will be expanded.

If you have thought of this, please let me know.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -