V
V
Vetal Matitskiy2015-10-22 09:24:00
Algorithms
Vetal Matitskiy, 2015-10-22 09:24:00

How to iterate over all possible combinations of n objects?

Good afternoon, I'm trying to write a program that would go through all possible combinations of n objects, or more specifically, we have an array containing integers without repetitions. For example, from [1,3,2] and you need to get a list of arrays [1,3,2], [1,2,3], [2,1,3] and so on
, I can’t figure out how to do this, but in the textbooks found only how to calculate the total number of such combinations. Please tell me where you can find similar algorithms and/or their implementations in programming languages

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
MiiNiPaa, 2015-10-22
@MiiNiPaa

their implementation in programming languages
C++, for example (see Possible implementation): next_permutation

P
protven, 2015-10-22
@protven

Recently answered this question, How to make all unique sequences from a one-dimensional array?

A
Anatoly Dudko, 2015-10-22
@Dudko

Try looking here www.cyberforum.ru/cpp-beginners/thread676321.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question