У меня есть ArrayList [] myList, и я пытаюсь создать список всех перестановок значений в массивах.
ПРИМЕР: (все значения являются строками)
myList[0] = { "1", "5", "3", "9" };
myList[1] = { "2", "3" };
myList[2] = { "93" };
Количество myList может меняться, поэтому его длина неизвестна заранее.
Я хотел бы иметь возможность генерировать список всех перестановок, похожих на следующие (но с некоторым дополнительным форматированием).
1 2 93
1 3 93
5 2 93
5 3 93
3 2 93
3 3 93
9 2 93
9 3 93
Означает ли это, чего я пытаюсь достичь? Я не могу придумать хороший способ сделать это (если есть).
Edit:
Я не уверен, что рекурсия будет мешать моему желанию форматировать вывод по-своему. Извините, я не упоминал до того, что мое форматирование было.
Я хочу создать массив строк [] из всех комбинаций, следующих за форматом, как показано ниже:
для перестановки "1 2 93"
Я хочу, чтобы выход был "val0 = 1; val1 = 2; val2 = 93;"
Сейчас я буду экспериментировать с рекурсией. Спасибо DrJokepu